[問題] c++ class中帶有參數的成員初始化
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
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 4 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章