作者readonly (唯读)
看板Programming
标题[问题] c++ class中带有参数的成员初始化
时间Sun Dec 16 18:04:06 2007
class A
{
public:
A( int c ){};
~A(){};
};
class B
{
public:
B(){};
~B(){};
A a( 5 ); // 这样不行吗?
};
会出现下列的错误讯息:
error: expected identifier before numeric constant
error: expected `,' or `...' before numeric constant
error: ISO C++ forbids declaration of `parameter' with no type
看来是把它当成一个function definition了,
不知道正确的写法是怎样呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.74.71.41