Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What does it mean to assign zero to a function?

Posted on 2013-06-10
4
Medium Priority
?
295 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 1000 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 1000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

916 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