这个答案有点奇怪
程序代码:
#include<iostream.h> class Myclass { private: int A,B,C; static int sum; public: Myclass(int a,int b,int c) { A=a;B=b;C=c; Myclass::sum=A+B+C; } void GetNumber(); void GetSum(); }; void Myclass::GetNumber() { cout<<"A = "<<A<<"\tB = "<<B<<"\tC = "<<C<<endl; } void Myclass::GetSum() { cout<<"sum = "<<Myclass::sum<<endl; } int Myclass::sum=0; void main() { Myclass M(3,7,10),N(14,9,11); M.GetSum(); N.GetSum(); } 为什么结果两个sum都是34