[問題] c++ class中帶有參數的成員初始化

看板Programming作者 (唯讀)時間18年前 (2007/12/16 18:04), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/4 (看更多)
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
文章代碼(AID): #17PFWNDn (Programming)
文章代碼(AID): #17PFWNDn (Programming)