精華區beta Programming 關於我們 聯絡資訊
※ 引述《milochen (作事專心很重要)》之銘言: : 有一個標準制定,制定了 Spec.h 的東東,而我必須要為Spec.h上的abstract class : 來來實作出對應的concrete class。 : 所以唯獨Spec.h裡的code不能更改就是了。 : //file : Spec.h : class AbstractBase : { : public: : virtual ~AbstractBase () : throw (); : virtual void someFunction () : throw (someException) = 0; : }; : #endif //_SPEC_H 首先澄清一個觀念, destructor 不可以被繼承, 一定要在 base class 裡實作完畢。 所以你需要一個 Spec.cpp: #include "Spec.h" AbstractBase::~AbstractBase() throw() { } 這樣就結束了, 因為你說 Spec.h 不能改, 所以我沒跟你說直接在 Spec.h 那邊把 ; 換成 { } 就好。 -- Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net School: National Tsing Hua University Department: Computer Science Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design Researching: Software pipelining for VLIW architectures Homepage: https://it.muds.net/~uranus -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.230.224.125
drkkimo:嗯~ 說的沒錯:)218.172.218.185 01/22 01:44