c++引用问题

[复制链接]
查看11 | 回复2 | 2011-10-30 13:38:41 | 显示全部楼层 |阅读模式
这个程序通不过编译的。错误若干。cat *boots=makecat(age);返回类型不匹配cout<using namespace std;class cat{public:cat(int age){itsage=age;}~cat() {}int getage()const{return itsage;}private:int itsage;};cat* makecat(int age);
//啥意思int main(){in...
回复

使用道具 举报

千问 | 2011-10-30 13:38:41 | 显示全部楼层
cat&makecat(int age);
//啥意思 --声明函数,返回值为对象cat的引用cat*makecat(int age)
{return new cat(age);
//返回什么 --返回值为对象cat的指针}cat *b...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行