Solved

static and virtual

Posted on 2004-10-15
1
296 Views
Last Modified: 2013-11-18
what the virtual means in the following context
a) class NewClass : public virtual oldclass

b) class AnotherClass
   {
    public:
      virtual void put(char*)
what the static means in the following context
a) class thirdclass
private:
static int size;

b) class lastclass
{
public:
   static bool isvalid(int day, int month, int year);

0
Comment
Question by:rmvprasad
[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
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 12320175
>> what the virtual means in the following context
>>a) class NewClass : public virtual oldclass

This means that 'oldclass' is a virtual base class, so the compiler will ensure that only one copy of the subobject 'oldclass' is included

>>b) class AnotherClass
>>  {
>>   public:
>>     virtual void put(char*)

This declares 'put()' as a virtual member function. A virtual function is a member function that you expect to be redefined in derived classes. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function.

>>what the static means in the following context
>>a) class thirdclass
>>private:
>>static int size;
>>b) class lastclass
>>{
>>public:
>>  static bool isvalid(int day, int month, int year);

In both cases, the static keyword specifies that one copy of the member is shared by all the instances of the class. When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members. Also, static members are the only members that can be used without actually referring to a certain instance of that class.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
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 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.

756 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