(1)
istream& getline (istream& is, string& str, char delim);
(2)
istream& getline (istream& is, string& str);
http://www.cplusplus.com/reference/string/string/getline/
istream& getline (istream& is, string& str, char delim);
(2)
istream& getline (istream& is, string& str);
http://www.cplusplus.com/reference/string/string/getline/
2017-02-24
已采纳回答 / qq_高等数学没有洛必达_0
void setName(string _name) // string 为数据类型 _name 为变量 声明了一个string型的函数变量_name{m_strName = _name; // 将 _name的值赋值给 m_strName}函数的作用就是把输入的值(_name)赋值给m_strName
2017-02-21
class Student
{
public:
void setname(string _name)
{
name=_name;
}
string getname()
{
return name;
}
private:
string name;
};
int main()
{
Student *str=new Student;
str->setname("muke");
cout<<str->getname()<<endl;
delete str;
str=NULL;
return 0;
{
public:
void setname(string _name)
{
name=_name;
}
string getname()
{
return name;
}
private:
string name;
};
int main()
{
Student *str=new Student;
str->setname("muke");
cout<<str->getname()<<endl;
delete str;
str=NULL;
return 0;
#include <iostream>
#include <string>
using namespace std;
/**
* 定义类:Student
* 数据成员:m_strName
}
// 定义数据成员封装函数getName()
string getName();
{return m_strName;}
//定义Student类私有数据成员m_strName
private:
string m_strName;
};
#include <string>
using namespace std;
/**
* 定义类:Student
* 数据成员:m_strName
}
// 定义数据成员封装函数getName()
string getName();
{return m_strName;}
//定义Student类私有数据成员m_strName
private:
string m_strName;
};