Solved

static and virtual

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

837 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