Containing and hiding information about an object, such as internal data structures and code.
What is inheritance?
Inheritance allows one class to reuse the state and behavior of another class.
What is Polymorphism?
Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.
What is destructor?
Destructor usually deletes any extra resources allocated by the object.
What is default constructor?
Default Constructor with no arguments or all the arguments has default values.
What is assignment operator?
Assignment operator handles assigning one object to another of the same class. Member to member copy……
What is difference between malloc(),free() and new,delete?
malloc allocates memory for object in heap but doesn’t invoke object’s constructor to initiallize the object.
new allocates memory and also invokes constructor to initialize the object.
malloc() and free() do not support object semantics
Does not construct and destruct objects
string * ptr = (string *)(malloc (sizeof(string)))
Are not safe
Does not calculate the size of the objects that it construct
Returns a pointer to void
int *p = (int *) (malloc(sizeof(int)));
int *p = new int;
Are not extensible
new and delete can be overloaded in a class
“delete” first calls the object’s termination routine (i.e. its destructor) and then releases the space the object occupied on the heap memory. If an array of objects was created using new, then delete must be told that it is dealing with an array by preceding the name with an empty []:-
Int_t *my_ints = new Int_t[10];
…
delete []my_ints;

