头文件#include<iostream>
#include<string>
using namespace std;
class Student
{
public:
void display();
void set_in();
private:
int num;
string name;
char sex;
#include<string>
using namespace std;
class Student
{
public:
void display();
void set_in();
private:
int num;
string name;
char sex;
};
源文件#include<iostream>
#include<stdlib.h>
#include<string>
#include"student.h"
using namespace std;
void Student::display()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
}
void Student::set_in()
{
cin>>num;
cin>>name;
cin>>sex;
}
int main()
{
Student s;
s.set_in();
s.display();
system("pause");
return 0;
}