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

x
?
Solved

static and virtual

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

Technology Partners: 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…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

730 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