Start Discovering Solved Questions and Your Course Assignments
TextBooks Included
Active Tutors
Asked Questions
Answered Questions
friend for overloading operatorssometimes friend functions cannot be avoided for example with the operator overloading consider the following class
using a friendusing a friend function is quite easy the following example explains a friend function to access members of two classesclass
friend functionsone of the major features of oop is information hiding a class encapsulates data and methods to operate on that data in a single unit
static member functionsall the objects of the class share static data members of a class the example above demonstrates how to keep track of all the
static class membersas we already know all the objects of the class have dissimilar data members but invoke the similar member functions though there
write a program of constructors and destructorsmake a class drugs having encapsulated data for medicine name whether solid or liquid price and
pure virtual functionsan abstract class is one which is used just for deriving some other classes no object of this class is declared and used in the
virtual functionsthe keyword virtual was previously used to resolve ambiguity for a class derived from two classes both having a common ancestor
abstract classesabstract classes are the classes which are written just to act as base classes consider the following
virtual base classesthis ambiguity can be resolved if the class derived have only one copy of the class base this can be done by making the base
multiple inheritance with a common base hybrid inheritanceinheritance is an important and powerful feature of oop only the imagination of the person
problems with multiple inheritancethe following example presents a problem with multiple inheritanceclass aclass public void
multiple inheritancemultiple inheritance as the name suggests is deriving a class from more than one class the derived class inherits all the
multilevel inheritancein multilevel inheritance there is a parent class from whom we derive another class now from this derived class we can derive
nested classesmany a times it becomes essential to have a class contain properties of two other classes one way is to explain a class within another
object conversionsjust like initialization conversions are also done automatically when an object of a derived class is assigned to an object of the
object initializationan object of a derived class can be initialized to an object of a base class if both the classes have similar data members then
constructor and destructor function with derived classesif there are constructors included in the base class and the derived class the compiler
hiding overloaded functionswe cannot overload a base class function by redefining it in a derived class with a dissimilar argument list consider
access privileges1 if the designer of the base class needs no one not even a derived class to access a member then that member should be made
derivations1 regardless of the type of derivation private members are inherited by the derived class but cannot be accessed by the new member
protected derivationin addition to doing private and public derivations you may also do a protected derivation in this situation the private
public derivationpublic derivations are much more common than private derivations in this situation the private members inherited from the base class
private derivationif no specific derivation is listed then a private derivation is supposed if a new class is derived privately from its parent class
how to define a derived class a singly inherited derived class id defined by writing the keyword class the name of the derived class a single colon