主题:[讨论]谁能指出以下程序错误?
指出以下程序中的错误,并加以修改。
#include<iostream.h>
class A
{
protected:
int a;
public:
void SetData(int x) { a=x;}
int GetData() { return ; }
};
class B
{
protected:
int b;
public:
void SetData(int y) { b=y; }
int GetData() {return b; }
};
class C : public A,public B
{
public:
void SetData(int x,int y) { a=x; b=y; }
};
void main()
{
C c;
c.SetData(30,70);
cout<<"a="<<c.GetData()<<", b="<<c.GetData()<<endl;
}
#include<iostream.h>
class A
{
protected:
int a;
public:
void SetData(int x) { a=x;}
int GetData() { return ; }
};
class B
{
protected:
int b;
public:
void SetData(int y) { b=y; }
int GetData() {return b; }
};
class C : public A,public B
{
public:
void SetData(int x,int y) { a=x; b=y; }
};
void main()
{
C c;
c.SetData(30,70);
cout<<"a="<<c.GetData()<<", b="<<c.GetData()<<endl;
}