已采纳回答 / 罗毅豪
#include<iostream>#include<stdlib.h>#include<string>using namespace std;int main(){string name;cout << "please input your name:" << name;getline(cin, name);if (name.empty()){cout << "input is null..." << endl;retu...
2016-04-10
已采纳回答 / 慕UI5843414
格式:getline(输入流即cin,string对象定义的变量)使用:getline(cin,string stu)从输入流中读入一行到变量stu中。输入空格即输入结束。
2016-04-10
最赞回答 / fy491423
int getMaxOrMin(int *arr, int count, bool isMax){ int temp = arr[0]; for (int i = 1; i < count; i++) { if (isMax) { if (temp < arr[i]) { temp = arr[i]; } } else { if (temp > arr[i]) { temp = arr[i]; } } }return temp;}获取最大值...
2016-04-07
class Student
{
public:
void setName(string _name){
m_strName = _name;
}
string getName(){
return m_strName;
}
private:
string m_strName;
};
int main()
{
Student *str = new Student;
str->setName("慕课网");
cout<<str->getName();
delete str;
str = NULL;
return 0;
}
输出: 慕课网
{
public:
void setName(string _name){
m_strName = _name;
}
string getName(){
return m_strName;
}
private:
string m_strName;
};
int main()
{
Student *str = new Student;
str->setName("慕课网");
cout<<str->getName();
delete str;
str = NULL;
return 0;
}
输出: 慕课网