do static method get inherited ?

I

Ivan Vecerina

: do static method get inherited ?
: if no why ?

What do you mean by "get inherited" ?

They do become accessible within the scope of the derived class:

class Base {
public: static void foo();
};

class Derived : public Base {
};

int main()
{
Derived::foo();
}


What more would you expect ?

Ivan
 
M

mangesh

thanks for reply .

but if i write
derived.foo() ;
will it compile ?

regards
mangesh
 
J

Jonathan Mcdougall

mangesh said:
thanks for reply .

[context: asking about the syntax for calling a static member function]
but if i write
derived.foo() ;
will it compile ?

[ Please, quote some context when you reply.
See http://en.wikipedia.org/wiki/Top-post#Inline_replies for more
informations. Also, unless Google Groups goofed, you seem to have
replied to your own post. Don't do that. Reply to the post you are
answering to (doesn't it make sense?) ]

Why don't you try it?

Don't guess about language features. Buy a good book (see www.accu.org
for suggestions) and study it.

A static member function is called either with

class_name::f();

or

object_name.f();


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top