answersLogoWhite

0


Best Answer

An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Yes an abstract class can inherit from another abstract class but all the methods of the base abstract class must be abstract.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is an abstract class cannot have any member variable in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you call an abstract class from main method?

An abstract class cannot have a constructor and hence you cannot invoke the constructor of the class - i.e., you can instantiate an abstract class and hence you cannot call the constructor of an abstract class.


Difference between abstract and final class?

Abstract class is built to promote inheritance whereas a final class is built to avoid inheritanceAn Abstract class can be extended by another class whereas a final class cannot be extended


What happens if an abstract modifier is applied to class. Explain?

The classes which have one or more abstract methods are abstract. To declare a class as abstract, use the abstract keyword in front of the class keyword, before the class declaration. Abstract classes cannot be instantiated. Similarly the new keyword cannot be used to create an object of the abstract class. Remember that the constructors and static variables cannot be declared as abstract. Any subclass of an abstract class must either implement all of the abstract methods in the superclass or be itself declared abstract.


What is the static variable in the class in c?

A static member variable is local to the class rather than to an object of the class.


What exception will be thrown when abstract class is instantiated?

None. Because an abstract class cannot be instantiated.


Is it true that Abstract class objects never have to be instantiated?

Yes. An Abstract class cannot be instantiated.


What is static variable in the class for c plus plus?

Static member variables are local to the class. That is, there is only one instance of a static member variable, regardless of how many objects are instantiated from the class. As such, they must be declared inside the class, and defined outside of the class.


What is the difference between abstract class and normal class?

Any class which has one or more abstract methods is called an abstract class. But in the normal class we can't have any abstract methods. We cannot create an object for the abstract classes. When we inherit the abstract class we should implement the abstract method which we inherit.


Create an instance to an abstract class?

You cannot create an instance of an abstract class. For ex: Public abstract AbsTest { … } AbsTest ex = new AbsTest(); Lets say we have a class declaration AbsTest that is abstract and then I try to instantiate it, the compiler will give me an error stating that "An Abstract class cannot be instantiated"


What is the need to create an abstract class without abstract?

Actually there is no need & most importantly - you cannot create an abstract class without using the abstract keyword


Can you have a final abstract class?

No. The abstract keyword means that you cannot instantiate the class unless you extend it with a subclass. The final keyword means that you cannot create subclasses of that class.Combining them would lead to an unusable class, so the compiler will not let this happen.


What is true about true about abstract data type Object of an abstract class type cant be created. We can derive classes from these abstract classes Object of an abstract class t?

True - an instance of an abstract class cannot be created. False - derive (subclass) from a class, not the object (the instance).