PC Review


Reply
Thread Tools Rate Thread

Why I can not create the type?

 
 
Larry
Guest
Posts: n/a
 
      24th Sep 2003
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


 
Reply With Quote
 
 
 
 
Nishant S
Guest
Posts: n/a
 
      25th Sep 2003
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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger Microsoft ASP .NET 4 21st Dec 2006 02:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger Microsoft ASP .NET 2 2nd Dec 2006 04:46 PM
why why why can't image icons on desktop be thumbnails Afton Wynona Windows XP General 2 29th Sep 2006 04:41 PM
Why?Why?Why?Why? Doug Microsoft Word New Users 4 8th Jun 2004 05:28 PM
*****Can't Hibernate... Why? Why? Why?***** Papa Smurf Windows XP General 2 3rd Jan 2004 12:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:47 PM.