正在加载图片...
例9.1 Tpiont: Piont(Piont include <iostream.h> &p) class Piont i x-p.X, y-p y cout<<”copy public: constrictor called\n”; Piont(int ix, int iy) void funI(Piont q) XIX 9 y=ly, cout<<"In function cout<” constructor called\n”,; funl(n”; Piont(piont p) Piont( Piont fun20 {cout<“ Destructorcalled\n”;} i Piont T(10, 20) int xcordo return x; j return T int ycordo i return y private: int x, y;#include <iostream.h> class Tpiont { public: Tpiont(int ix, int iy) { x=ix ; y=iy; cout<<”constructor called\n”; } Tpiont(Tpiont & p); ~Tpiont() { cout<< “Destructorcalled\n”; } int xcord() {return x; } int ycord() {return y; } private: int x, y; }; Tpiont::Tpiont(Tpiont & p) { x=p.x; y=p.y; cout<<”copy constrctor called\n”; } void fun1(Tpiont q) { cout<<”In functiont fun1()\n”; } Tpiont fun2() { Tpiont T(10,20); return T; } 例 9.1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有