Solved

What does it mean to assign zero to a function?

Posted on 2013-06-10
4
287 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
ID: 39235984
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
 
LVL 1

Author Comment

by:naseeam
ID: 39235999
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
ID: 39236023
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
 
LVL 1

Author Closing Comment

by:naseeam
ID: 39236196
Excellent concise answers!  Short but complete.

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

765 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