#include<iostream>
using namespace std;
試試。
將上面兩句拿到妳定義類的文件的上面去。
如下:
#include <stdio.h>
#include <iostream.h>
using namespace std;
class myclass
{
private:
int x,y;
public:
myclass (int x=0,int y=0)
{
this->x=x;this->y=y;
}
void print ()
{
cout<<"x=:"<<x<<endl; cout<<"y=:"<<y<<endl;
}
~myclass ()
{
cout<<"hello"<<endl;
}
};
int main(void)
{
myclass my1,my2(3,4);
cout<<"my1:";
my1.print();
cout<<"my2:"; my2.print();
}