Make the Eat, Sleep and Work functions public in the SoftwareDeveloper
class.
--
Regards,
Nish [VC++ MVP]
"Larry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> These is a interface " IPerson" and a class "SoftwareDeveloper" support
> the interface;
>
> public __gc __interface IPerson
>
> {
> void Eat();
> void Sleep(;
> void Work();
>
> };
>
> public __gc class SoftwareDeveloper : public IPerson
>
> {
> ~SoftwareDeveloper()
> {
> System::Console::WriteLine("Finalize called for SoftwareDeveloper");
> }
>
> void Eat()
> {
> System::Console::WriteLine("Eat pizza");
> }
>
> void Sleep()
> {
> System::Console::WriteLine("Sleep during the day");
> }
>
> void Work()
> {
> System::Console::WriteLine("Work during the night");
> }
> };
>
> But I can not use "new" to create an instance of the class,
>
> SoftwareDeveloper * pSoftwareDeveloper=new SoftwareDeveloper;
>
> there 's a error message:
> f:\Test\c++\Ex32a\Ex32a.h(167) : error C2259: 'Ex32a::SoftwareDeveloper' :
> cannot instantiate abstract class
> due to following members:
> 'void Ex32a::IPerson::Eat(void)' : pure virtual function was not defined
> f:\Test\c++\Ex32a\Ex32a.h(62) : see declaration of 'Ex32a::IPerson::Eat'
> 'void Ex32a::IPerson::Sleep(void)' : pure virtual function was not defined
> f:\Test\c++\Ex32a\Ex32a.h(63) : see declaration of 'Ex32a::IPerson::Sleep'
> 'void Ex32a::IPerson::Work(void)' : pure virtual function was not defined
> f:\Test\c++\Ex32a\Ex32a.h(64) : see declaration of 'Ex32a::IPerson::Work'
>
> What cause this problem and How can I get rod of it?
>
> Thanks ahead.
>
> Larry
>
>
|