Solved

What does it mean to assign zero to a function?

Posted on 2013-06-10
4
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

628 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