Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2004

Tip: Looking for answers? Try searching our database.

Property with pure virtual function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adriano Coser - 22 Jul 2004 14:35 GMT
Hi. I'm declaring a property on a base class that is represented by a
pure virtual function. Something like this:

public:
 __declspec( property( get=GetWidth ) ) int Width;
 virtual int GetWidth() = 0;

I'm implementing GetWidth in all subclasses, but I got the following
linker error:

QIVReport error LNK2001: unresolved external symbol "public: virtual
int __thiscall TMyAbstractClass::GetWidth(void)"
(?GetWidth@TMyAbstractClass@@UAEHXZ)

If I turn the function non-pure the error desapears.

Is there a way to use a pure virtual function to represent a property?

Thanks in advance for any help.

Regards,
Adriano.
Vince Yuan - 27 Jul 2004 01:43 GMT
a property cannot be a pure virtual function

Vince

> Hi. I'm declaring a property on a base class that is represented by a
> pure virtual function. Something like this:
[quoted text clipped - 18 lines]
> Regards,
> Adriano.
David Olsen - 27 Jul 2004 19:17 GMT
> a property cannot be a pure virtual function

But it seems like there is a relatively simple workaround (which I
haven't tested):

public:
  __declspec( property( get=DoGetWidth ) ) int Width;
  int DoGetWidth() { return GetWidth(); }
  virtual int GetWidth() = 0;

DoGetWidth could probably be private, since there is no good reason (in
this particular case) to expose it.  DoGetWidth and GetWidth should
probably be const member functions.

>>Hi. I'm declaring a property on a base class that is represented by a
>>pure virtual function. Something like this:
[quoted text clipped - 13 lines]
>>
>>Is there a way to use a pure virtual function to represent a property?

Signature

David Olsen
qg4h9ykc5m@yahoo.com

tom_usenet - 28 Jul 2004 12:46 GMT
>Hi. I'm declaring a property on a base class that is represented by a
>pure virtual function. Something like this:
[quoted text clipped - 13 lines]
>
>Is there a way to use a pure virtual function to represent a property?

You could try providing an implementation for the pure virtual
function (while leaving it pure virtual).

Tom.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.