对象指针
// 对象指针.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
class Student
{
int id;
char name[10];
float score;
public:
Student(int pid, char *pname, float s);
void displsy();
};
Student::Student(int pid, char * pname, float s)
{
id = pid;
strcpy(name, pname);
score = s;
}
void Student::displsy()
{
cout << "id:" << id << endl;
cout << "name:" << name << endl;
cout << "score:" << score << endl;
}
int main()
{
Student s1(1511435,"nankai",56);
s1.displsy();
Student *p = &s1;
p->displsy();
return 0;
}