程序老是报错,关于类的引用
#include<iostream>void main()
{
class Cat
{public:
Cat(int age,int weight);
~Cat(){}
int getage(){return itsage;}
int getweight(){return itsweight;}
private:
int itsage;
int itsweight;
};
Cat::Cat(int age,int weight)
{itsage=age;
itsweight=weight;
}
Cat frisky(5,8);
cout<<"frisky age:"<<frisky.getage()<<endl;
cout<<"frisky weight"<<frisky.getweight()<<endl;
Cat & rfrisky=frisky;
cout<<"rfrisky age:"<<rfrisky.getage()<<endl;
cout<<"rfrisky weight"<<rfrisky.getweight()<<endl;
}
我用的是C-free ,构造函数定义那一行老是报错,到底哪有问题,望诸位赐教!
谢谢。