473,499 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do static method get inherited ?

do static method get inherited ?
if no why ?

Regards
Mangesh

Jun 4 '06 #1
4 1960
"mangesh" <ma************@walla.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
: 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
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Jun 4 '06 #2

thanks for reply .

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

regards
mangesh

Jun 4 '06 #3
mangesh wrote:

thanks for reply .

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

regards
mangesh


No, you must write DERIVED::foo() !

Jun 4 '06 #4
mangesh wrote:
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

Jun 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6999
by: Dave | last post by:
In Exceptional C++, the following code snippet appears at the bottom of page 197: template<class T> class Array : private ArrayBase, public Container { typedef Array AIType; public: Array(...
0
1292
by: Bryan Green | last post by:
So I'm working on a project for a C# class I'm taking, where I need to keep some running totals via static variables. I need three classes for three different types of objects. The base class and...
3
6631
by: Danny Din | last post by:
Hi, I have the following code – public class Class1 { public Class1()
19
24564
by: Mike Ruane-Torr | last post by:
Why can't I have a static abstract method in C#? My intention is to have a class-level method that returns a string to supply information about inherited classes, and it is natural to make this...
3
11807
by: Kirk Marple | last post by:
Just want to see if this is 'by design' or a bug... I have a common List<T> defined in a base class, and the base class has a static property to expose this list. I wanted the derived class to...
4
10730
by: Bryan Green | last post by:
So I'm working on a project for a C# class I'm taking, where I need to keep some running totals via static variables. I need three classes for three different types of objects. The base class and...
5
3593
by: Eliseu Rodrigues | last post by:
Hi I would like to have a static method on a base class that executes some action (for example retrieves the row count) on a table whose name is the same of the inherited class name. For...
4
2866
by: mfc | last post by:
How do i get the type info in a static method? for instance in the code below is it possible for the Method to get the type to know what type was used to call Method? thanks class C {
14
1618
by: d-42 | last post by:
Hi, Is there any way to make this method inheritable and have it behave appropriately on inherited classes? Using generics? Extension methods? Something else? class baseClass { public...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.