【3.25】 写出下面程序的运行结果。 #include
using namespace std; class M{ int x,y; public: M() { x=y=0; }
M(int i,int j) {x=i; y=j; }
void copy(M*m); void setxy(int i,int j) {x=i;
y=j; }
void print()
{cout< void M::copy(M*m) {x=m->x; y=m->y; } void fun(M m1,M*m2) {m1.setxy(12,15); m2->setxy(22,25); } int main() {M p(5,7),q; q.copy(&p); fun(p,&q); p.print(); q.print(); return 0; } 答:运行结果是 5,7 22,25 【3.26】 写出下面程序的运行结果。 #include using namespace std; class M{ int A; static int B; public: M(int a) {A=a; B+=a; cout<<\ } static void f1(M m); ~M() {cout<<\ } }; void M::f1(M m) {cout<<\ cout<<\} int M::B=0; int main() {M p(5),Q(10); M::f1(p); M::f1(Q); return 0; } 答:运行结果是 Constructing Constructing A=5 B=15 Destructing A=10 B=15 Destructing Destructing Destructing 【3.27】 指出下列程序中的错误,并说明为什么。 #include using namespace std; class Student{ public: void printStu(); private: char name[10]; int age; float aver; }; int main()