Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 32 - 33 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 32

C & C Plus Plus

Describe in Detail


What are virtual functions?


Understanding Virtual Functions
  • A member function excepted to be redefined in derived classes.
  • It is used when a derived class object is referred using a pointer to the base class- virtual function call through base class pointer executes the derived class version of the function.
  • Virtual functions ensure that the correct function is called for an object, regardless of the type of reference used for function call.
  • Mainly used to achieve runtime polymorphism.
  • Functions are declared with a virtual keyword in base class.

Question 33

C & C Plus Plus

Write in Short

Short Answer▾

Differentiate between the message and method.


Differentiate between the Message and Method
Objects communicate by sending messages to each other.Provides response to a message.
A message is sent to invoke a method.It is an implementation of an operation.
Message refers to instruction sent to object which will invoke the related method.Method is a function or procedure that is defined for a class and typically can access the internal state of an object of that class to perform some operation.
A message is any packet of communication between objects. The objects may be in the same program, or they may be on different systems. It simply doesn՚t matter.A method is a block of code attached to an object by some means. It may be implicitly attached by means of a class, or it may be an anonymous closure attached to an arbitrary attribute of the object.

Developed by: