//X.h class X{ public: int f1(); int f2(); protected: int m; }; //X.cpp int X::f1() { int m = 5; cout<<"f1: m = "<<m<<endl; return m; } int X::f2() { int m=3; cout<<"f2: m = "<<m<<endl; return m; } //main.cpp int main() { X x; cout<<x.f1()<<x.f2(); return 0; }
为什么输出结果是
f2: m = 3
f1: m = 5
53
而不是
f1: m = 5
f2: m = 3
53
onemoo
___C___
慕设计7118955
相关分类