来自「visualCplusplus学习课件大连东软培训教材」· 代码 · 共 45 行

TXT
45
字号
#include <iostream>
using namespace std;

class Student
{
public:
	Student(char *pName = "no name", int ssId=0);
	Student(const Student& Stu);
	~Student();
protected:
private:
	int m_ID;
	char m_cName[40];
};

Student::Student(char *pName, int ssId)
{
	m_ID = ssId;
	strcpy(m_cName, pName);
	cout << "construct new student" <<endl;
}

Student::Student(const Student& Stu)
{
	m_ID = Stu.m_ID;
	strcpy(m_cName, Stu.m_cName);
	cout << "construct copy of" << Stu.m_cName << endl;
}

Student::~Student()
{
	cout << "destructing" << endl;
}

void Fun(const Student& s)
{
	cout << "in fun()" << endl;
}

void main()
{
	Student randy("randy", 1234);
	Fun(randy);
	cout << "returned from fun()" << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?