Solved

What does it mean to assign zero to a function?

Posted on 2013-06-10
4
280 Views
Last Modified: 2013-06-10
class Socket
{
  public:
   ...
   ..
   virtual ~Socket() {};

    virtual signed int close    () = 0;



What does it mean to assign 0 to close()?
0
Comment
Question by:naseeam
  • 2
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 250 total points
Comment Utility
It means that 'close()' is declared as a so called 'pure virtual' function, i.e. is expected to be overridden by a derived class. You cannot instantiate a class that has any pure virtual functions, they serve as a "interface definition". See also http://www.exforsys.com/tutorials/c-plus-plus/c-pure-virtual-function-and-base-class.html
0
 

Author Comment

by:naseeam
Comment Utility
class Socket
{
  public:
   ...
   ..
   virtual ~Socket() {};

    virtual signed int close    () = 0;


   /* Is this also pure virtual fucntion?  Will this be overridden by derived class
      as well. */
   virtual signed int openWait () {return SocketErrorValue_None;}
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
Comment Utility
No, this funtion is virtual, not "pure virtual". That means you canoverwrite it, but - as opposed to "pure virtual" - you don't have to.
0
 

Author Closing Comment

by:naseeam
Comment Utility
Excellent concise answers!  Short but complete.

Great link on C++ training.  Thank you so much!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now