/*
时间:2020年5月9日18:38:36
地点:青木树
功能:类的指针使用*/
#include <iostream>
using namespace std;
class Student {
public:
//创建数据成员
const char* name;
int age;
int number;
float score;
//创建成员函数
void say() {
cout << name << endl;
cout << number << endl;
cout << age << endl;
cout << score << endl;
}
};
int main() {
//创建指针对象
Student* pStu = new Student;
pStu->name = "小明";
pStu->number=6019203034;
pStu->age = 21;
pStu->score = 92.5f;
pStu->say();
delete pStu; //删除对象
return 0;
}
//知识点:注意new 和delete成对使用。
//指针的调用方法:class_name *指针名=new class_name;
原文:https://www.cnblogs.com/qq1480040000/p/12859443.html