Programing IN C++ : part 2

 

Programing IN C++


*      What is polymorphism?

*      Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol, containing differing types of objects. Consider 1 + 5 and 1 + 5.1. In the former, the message “+ 5″ is sent to an object of class integer (1). In the later, the message “+ 5.1″ is sent to the same integer object. The form of the message (its protocol) is identical in both cases. What differs is the type of object on the right-hand side of these messages. The former is an integer object (5) while the later is a floating point object (5.1). The receiver (1) appears (to other objects) to respond in the same way to both messages. Internally, however, it knows that it must treat the two types of objects differently in order to obtain the same overall response.

*      Polymorphism refers to the ability to have more than one method with the same signature in an inheritance hierarchy. The correct method is invoked at run-time based on the context (object) on which the method is invoked. Polymorphism allows for a generic use of method names while providing specialized implementations for them.

*      What are instance variables?

*      These represent an object’s private memory. They are defined in an object’s class.

*      What are class variables?

*      These represent a class’s memory which it shares with each of its instances.

*      What is a method?

*      A method is a class’s procedural response to a given message protocol. It is like the definition of a procedure in other languages.

*      In C++ what is a constructor? A destructor?

*      A constructors and destructors are methods defined in a class that are invoked automatically when an object is created or destroyed. They are used to initialize a newly allocated object and to cleanup behind an object about to be removed.

Anic_an_engineer

Hi, I am Anic an IT Professional . I like to share my knowledge and experience. Thanks for visiting my site.

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post