#include<iostream>#include<string>
using namespace std;
class Screen;// 只是类声明
class LinkScreen{
Screen *window;
LinkScreen *next;
LinkScreen *prev;};
class Y;
class X
{// 各种成员忽略
private:
Y *ptr;};
class Y
{// 各种成员略
private:
X Obj;
X *ptr;};// 记录
class Record // 这是一个完整的类: 类定义,类声明{
public:typedef std::size_t size;Record():byte_count(0){}Record(size s):byte_count(s){}Record(std::string s):name(s),byte_count(0){}
size get_count()const{return byte_count;}
std::string get_name()const{return name;}
private:
size byte_count;
std::string name;// 记录的名称 };intmain(){
Screen *sr;// 对于类声明 不能定义对象,可以定义指针
Record r;// 在堆栈上创建类的对象
class Record r2;// c 的写法//Record r2; // c++ 的写法
Record *p = new Record;// 在堆上动态的创建对象
delete p;
cout <<"test"<< endl;return0;}