Solved

static and virtual

Posted on 2004-10-15
1
282 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
How to update Firmware and Bios in Dell Equalogic PS6000 Arrays and Hard Disks firmware update.
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.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now