请大家看看问题在哪儿?
#include <iostream.h>
class Ex1
{
private:
int x;
public:
void setdata(int i)
{
x=i*2;
}
void print();
}
class Ex2
{
private:
int y;
public:
void setdata(int j)
{
x=j*j;
}
void print();
}
void Ex1::print()
{
cout<<"class 1:"<<x<<endl;
}
void Ex2::print()
{
cout<<"class 2:"<<y<<endl;
}
void main()
{
Ex1 s;
Ex2 t;
s.setdata(5);
s.print();
t.setdata(5);
t.print();
}
问题描述:
left of".print" must have class/struct/union type