Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What does it mean to assign zero to a function?

Posted on 2013-06-10
4
Medium Priority
?
292 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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…

721 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