1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include "iostream" using namespace std;
class ABCD { public: ABCD(int a, int b, int c) { this->a = a; this->b = b; this->c = c; printf("ABCD() construct, a:%d,b:%d,c:%d \n", this->a, this->b, this->c); } ~ABCD() { printf("~ABCD() construct,a:%d,b:%d,c:%d \n", this->a, this->b, this->c); } int getA() { return this->a; } protected: private: int a; int b; int c; };
class MyE { public: MyE() :abcd1(1, 2, 3), abcd2(4, 5, 6), m(100) { cout << "MyD()" << endl; } ~MyE() { cout << "~MyD()" << endl; } MyE(const MyE & obj) :abcd1(7, 8, 9), abcd2(10, 11, 12), m(100) { printf("MyD(const MyD & obj)\n"); }
protected: public: ABCD abcd1; ABCD abcd2; const int m;
};
int doThing(MyE mye1) { printf("doThing() mye1.abc1.a:%d \n", mye1.abcd1.getA()); return 0; }
int run2() { MyE myE; doThing(myE); return 0; }
int run3() { printf("run3 start..\n");
ABCD abcd = ABCD(100, 200, 300); printf("run3 end\n"); return 0; }
int main() { run2(); system("pause"); return 0; }
|