新建 文本文档.txt
来自「用什么语言能编制出好的程序」· 文本 代码 · 共 30 行
TXT
30 行
#include<iostream.h>
class TA
{
public:
TA(){cout<<"construction the class TA"<<endl;}
~TA(){cout<<"destruction the class TA"<<endl;}
void f(){cout<<"You are the best boy"<<endl;}
};
class TsmartA
{
public:
TsmartA (TA* pt):ptr (pt){cout<<"construction the class TsmartA"<<endl;}
~TsmartA()
{
cout<<"destruction the class TsmartA"<<endl;
delete ptr;
}
TA* operator->() {return ptr;}
operator bool(){return ptr;}
private:
TA* ptr;
};
int main()
{
TsmartA sa(new TA);
// sa->f(); //在这里相当于sa.operator->())->f()
if(sa)
sa->f();
return 1;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?