C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 4th, 2002, 11:05 PM
justin_dago justin_dago is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: new york
Posts: 84 justin_dago User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Question Method Question

Code:
virtual methodName() = 0;


i've come across this in a book, and i'm wondering what the "= 0" bit is all about



any insight would be greatly appreciated

justin.dago

Reply With Quote
  #2  
Old September 5th, 2002, 09:42 AM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 12
If this is C++, then it makes the method a pure virtual function. Any class that contains a pure virtual function cannot be instantiated; you must derive a base class in order to use it.
__________________
Jon Sagara

"Me fail English? That's unpossible!"

Reply With Quote
  #3  
Old September 5th, 2002, 10:34 AM
rendy's Avatar
rendy rendy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: London
Posts: 349 rendy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 19 m 21 sec
Reputation Power: 11
Remember though that declaring a method pure virtual doesn't mean that it can not have an implementation.

Declaring it pure virtual means that the current class is abstract and that any concrete class inheriting from the surrent class must declare the function as a "normal" virtual function.
__________________
Invoice Software

here

click here

Reply With Quote
  #4  
Old September 5th, 2002, 11:28 PM
justin_dago justin_dago is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: new york
Posts: 84 justin_dago User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
the = 0 makes it a "pure" virtual function...??

i was not aware there were different types of virtual functions????

Reply With Quote
  #5  
Old September 5th, 2002, 11:31 PM
jonsagara's Avatar
jonsagara jonsagara is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: USA
Posts: 286 jonsagara User rank is Private First Class (20 - 50 Reputation Level)jonsagara User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 m 23 sec
Reputation Power: 12
http://msdn.microsoft.com/library/d...tion_Syntax.asp

A pure virtual function MUST be overridden in a base class. A plain virtual function may optionally be overridden.

Reply With Quote
  #6  
Old September 6th, 2002, 09:17 PM
justin_dago justin_dago is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: new york
Posts: 84 justin_dago User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
great. thanks a lot guys. i'm checking that link now. thanks again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Method Question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap