首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

按别名传递对象程序中有关问题

2012-04-18 
按别名传递对象程序中问题运行下面程序后有一个错误 “missing function header (old-style formal list?)”

按别名传递对象程序中问题
运行下面程序后 有一个错误 “missing function header (old-style formal list?)” 这是神马意思啊 请指点啊 谢谢啊  

#include <iostream> 
using namespace std;
class A
{
public:
A(){cout<<"执行构造函数创建一个对象\n";}
A(const A& a){cout<<"执行构造函数创建该对象的副本\n";}
~A(){cout<<"执行析构函数删除该对象\n";}

void set(int i){x=i;}  
int get()const{return x;} 
private:
int x;
};
A& func(A &one);
{
return one;
}
int main()
{
  A a;
a.set(11);
A &b=func(a);
cout<<b.get()<<endl;
return 0;
}



[解决办法]
A& func(A &one);// 这个分号
{
return one;
}

[解决办法]
A& func(A &one);
多了个分号
A& func(A &one)
[解决办法]

C/C++ code
A& func(A &one) //多了一个分号{    return one;}
[解决办法]
A& func(A &one); //分号去掉

热点排行