Can we call a base class method without creating instance?
Answers were Sorted based on User's Feedback
Answer / nk
Onlu static methods can be called without creating any
instance of the class.
| Is This Answer Correct ? | 23 Yes | 1 No |
Answer / amit sharma
U've to derieve the class first and then when u instanciate
the derieved class. Then :-
U can call it using derieved class object or in a derieved
class member function depending upon base class fun's acess
specifer and inheritence specifier.
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / sanjay makwana, puna
e.g. class X
{
int x;
X()
{
cout << "X";
}
public :
static void fun()
{
cout << "fun";
}
};
you may called like
X::fun();
| Is This Answer Correct ? | 10 Yes | 3 No |
Answer / vijaya
by declaring that method as static we have call it without creating instance of that class.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is purpose of inheritance?
What is difference between oop and pop?
What is variable example?
How long to learn object oriented programming?
Can we have a private constructor ?
12 Answers HSBC, Ness Technologies, TCS, Wipro,
explain dynamic binding by drowing
What is abstraction oop?
What is the difference between inheritance and polymorphism?
write a program for function overloading?
14 Answers HCL, InfoCity, TATA,
what is multithreading in c++ , what is difference between multithreading and singlethreading.
how to swap the variables without using temp and operators
What does the code "cout<<(0==0);" print? 1) 0 2) 1 3) Compiler error: Lvalue required