#include
class Sample
{
int n;
static int sum ;
public:
Sample(int x)
{
n = x ;
}
void add()
{
sum += n ;
}
void display()
{
cout << "n=" << n << ",sum=" << sum << endl ;
}
};
int sum=0
void main()
{
Sample a(2), b(3), c(5) ;
a.add() ;
a.display() ;
b.add() ;
b.display() ;
c.add() ;
c.display() ;
}
#include
class Sample
{
// ERROR**********found**********
int n;
static int sum ;
public:
// ERROR**********found**********
Sample(int x)
{
n = x ;
}
void add()
{
sum += n ;
}
void display()
{
cout << "n=" << n << ",sum=" << sum << endl ;
}
};
// ERROR**********found**********
int sum=0;
void main()
{
Sample a(2), b(3), c(5) ;
a.add() ;
a.display() ;
b.add() ;
b.display() ;
c.add() ;
c.display() ;
}
把有error的下一句改一下最后能对,就行!
|