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 the difference between class and object?
Can destructor be overloaded?
What are the two different types of polymorphism?
Can we create object of interface?
What's the full form of STL?
What is multiple inheritance? Give Example
Why multiple inheritance is not allowed?
What is polymorphism ? Explain with examples
What is the difference between class and structure?
Why is destructor used?
What is a class and object?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer