类的成员函数
5、小作业:
类的声明和实现
大家自己课后用VS2013练习如何添加类吧
#pragma once #include <iostream> #include <string> using namespace std; class CStudent { string name; int age; public: void set_infor(string x,int y); };
#include "CStudent.h" void CStudent::set_infor(string x,int y) { name = x; age = y; cout << name << endl; cout << age << endl; }
#include "CStudent.h" int main() { CStudent zhangsan; zhangsan.set_infor("张三",50); return 0; }
浙公网安备 33010602011771号