Why I can not create the type?

L

Larry

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top