|
|
- [7]
- double & func(double & x,double & y)
- {
- double z;
- z=x+y;
- return z; //返回临时变量的引用是个很嚣张的做法,必将得到惩罚
- }
- [9]
- class Cat
- {
- int Age;
- public:
- void SetAge(int age){Age=age;}
- } //分号?
- [11]
- class A
- {
- public:
- void funcA();
- };
- class B:public A
- {
- public:
- void funcB(int x);
- void funcC(double x,double y);
- };
- void Test( )
- {
- A * Pt=new B;
- Pt->funcA( );
- Pt->funcB(5); //我可以和娃他娘亲热,但是不能和娃他媳妇亲热
- Pt->funcC(15.2,17.8); //同上
- delete Pt;
- }
- [13]
- class PPP
- {
- int data;
- friend void Print(PPP & obj);
- public:
- PPP(int x=0){data=x;}
- int GetData( ) const {return data;}
- void SetData(int x){data=x;}
- };
- void Print(PPP & obj)
- {
- cout<<obj.data;
- obj.SetData(20);
- cout<<obj.GetData( ); //虽然朋友可以随便欣赏我老婆,但是谁敢摸她,我就和他拼了
- }
复制代码 |
|