Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

static and virtual

Posted on 2004-10-15
1
Medium Priority
?
308 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 800 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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

782 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