学过java的人表示太轻松了,其实就只需三个明确就能搞定函数,即明确该函数的运算结果,其实就是明确该函数的返回值类型,明确该函数的参数列表,ok,搞定!!
2016-06-17
已采纳回答 / 443452169
第一个#我也不太清楚具体含义,第二个#要加上,因为你的类中有string类型的数据,第3行是命名空间,因为你用了打印数据的函数(方法),而那个方法是属于std这个指令集(方法库)的
2016-06-13
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
Student *p = new Student();
p->m_strName = "陈俊溢";
p->m_iAge = 28;
cout << p->m_strName << " " << p->m_iAge << endl;
delete p;
p = NULL;
return 0;
}
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
Student *p = new Student();
p->m_strName = "陈俊溢";
p->m_iAge = 28;
cout << p->m_strName << " " << p->m_iAge << endl;
delete p;
p = NULL;
return 0;
}
最新回答 / Timothy飞
编程中我们会实例化一个对象,实例化对象的过程:对象产生->对象使用->对象销毁。在这三个步骤中我们可以用不同的函数来对对象进行操作,对象产生用构造函数,对象使用 用对象函数成员,对象销毁用析构函数。
2016-06-12