Abstract Classes Can Be Instantiated As Long As You Dont Call Any Of The Pure Virtual Functions
Abstract classes are mainly used for upcasting so that its derived classes can use its interface.
Abstract classes can be instantiated as long as you dont call any of the pure virtual functions. Abstract class cannot be instantiated but pointers and refrences of abstract class type can be created. You cant directly instantiate an abstract class. Abstract classes cannot be instantiated. Calling a pure virtual function from a constructor is undefined behaviour even if it has an implementation.
Sizeof is a compile time operator to determine the size of a variable or type. When you refer to a derived class object using a pointer or a reference to the base class you can call a virtual function for that object and execute the derived classs version of the function. However you can use pointers and references to abstract class types. Abstract class can have normal functions and variables along with a pure virtual function.
If you want to make a component using characterstats it shouldnt be abstract. So far all of the virtual functions we have written have a body a definition. Abstract classes act as expressions of general concepts from which more specific classes can be derived. You may call a virtual function as long as it is not a pure virtual function and as long as you know that what you are calling is the method from the class itself and not expecting any polymorphism.
An abstract class is a class in c which have at least one pure virtual function. Cashcow mar 2 12 at 726. But you can extend it inherit it. You cant instantiate an abstract class.
Abstract class cannot be instantiated but pointers and references of abstract class type can be created. Abstract class can have normal functions and variables along with a pure virtual function. So id say no. Abstract classes can be instantiated as long as you dont call any of the pure virtual functions.
Pure virtual abstract functions and abstract base classes. You cannot create an object of an abstract class type. A class that contains at least one pure virtual function is considered an abstract class. Pure virtual functions.
I mean you can not instantiate the orginial abstract class but you can. However c allows you to create a special kind of virtual function called a pure virtual function or abstract function that has no body at alla pure virtual function simply acts as a placeholder that is meant to be redefined by derived classes. But it doesnt mean that you cant get an instance of class not actully an instance of original abstract class indirectly. If you want characterstats to be added as a component make it a normal or virtual class with virtual functions.
Sizeof is a run time operator that returns the size of the current operating stack sizeof is a run time operator that returns the size of the current. A virtual function a member function which is declared within a base class and is re definedoverriden by a derived class.