C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 8)
8.
How many instances of an abstract class can be created?
Discussion:
57 comments Page 3 of 6.
Priya said:
1 decade ago
Explain difference between instance of class and object of class?
Dnyaneshwar Jadhav said:
1 decade ago
By declaring class as a abstract we can not create any object belonging to that class.
K2u2007 said:
1 decade ago
A class that contains at least one pure virtual function is said to be abstract. Because an abstract class contains one or more functions for which there is no definition (that is, a pure virtual function), no objects of an abstract class may be created.
Instead, an abstract class constitutes an incomplete type that is used as a foundation for derived classes. Although you cannot create objects of an abstract class, you can create pointers.
And references to an abstract class. This allows abstract classes to support run-time. polymorphism, which relies upon base-class pointers and references to select the proper virtual function.
Instead, an abstract class constitutes an incomplete type that is used as a foundation for derived classes. Although you cannot create objects of an abstract class, you can create pointers.
And references to an abstract class. This allows abstract classes to support run-time. polymorphism, which relies upon base-class pointers and references to select the proper virtual function.
JITENDRA KUMAR SINGH said:
1 decade ago
May anyone explain with examples?
Aditya Bhonde said:
1 decade ago
To access a member function of abstract class we need not require a object. By creating a pointer of object we can call it or access it.
Abdul Rizwan said:
1 decade ago
@Bhavik.
Abstract class is used to reduce the complexity of method overriding or data hiding.
As we know abstract method don't have definition part, so for define the abstract method we must have to inherit the abstract class with some other base class.
And suppose we are able to create an object of an abstract class and we are calling the abstract method using object then in that abstract method don't have code so compiler will stuck and your program will hang over there.
So to reduce the problem or programmer don't make any mistake, Developer has put the restriction to create an object of an abstract class.
Instead of object we can create a reference variable of abstract class. Using ref variable also we can call abstract method but before calling we need to pass an object of base class to a ref variable.
Abstract class is used to reduce the complexity of method overriding or data hiding.
As we know abstract method don't have definition part, so for define the abstract method we must have to inherit the abstract class with some other base class.
And suppose we are able to create an object of an abstract class and we are calling the abstract method using object then in that abstract method don't have code so compiler will stuck and your program will hang over there.
So to reduce the problem or programmer don't make any mistake, Developer has put the restriction to create an object of an abstract class.
Instead of object we can create a reference variable of abstract class. Using ref variable also we can call abstract method but before calling we need to pass an object of base class to a ref variable.
Bhavik said:
1 decade ago
Can you tell me why we can't create the instance of an abstract class?
Basavaraj said:
1 decade ago
Abstract class never allowed to create an instance, hence answer is 0.
Rajaram said:
1 decade ago
When a class is act as a parent class for all other classes and it should not be get instantiated by any derived class.
Priyanka said:
1 decade ago
Can anyone tell me the exact implementation scenario where abstract class is used?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers