1 5 pts What is a const object 3 pts What kinds of functions
1. (5 pts) What is a const object (3 pts)? What kinds of functions can a const object invoke (2 pts)? Explain.
2. (5 pts) What is meant by information hiding? Explain.
3. (5 pts) What is an overloaded operator? Explain
Solution
1.
Const object:
Any variable which is associated by the keyword constant, the memory to such a variable is always given at the time of creation.
You can create any variable class type, primitive data type as a const variable by just adding a keyword constant.
A variable of class type known as object when declared with const keyword is known as const object.
Example I have a class of Employee and we create a class type emp, now just add const before emp at the time of creation then the object will become const object.
Kinds of functions that can be invoked by const object
const objects can only call const member functions
For example if I define a function addEmployee() as const then only the const objects can call these const member functions.
2.
Information hiding is a powerful technique of object oriented programming in which the object or method details are hided from the outside world.
By Information hiding we try to make critical information to be private from outside world.
In programming terms defining any attribute as private implements the information hiding technique.
3.
Operator overloading is a type of polymorphism. By operator overloading we assign a new operation to the basic operator for example plus operator(+) is use to add two operands we can overload it by just defining a method which will define a new operation to the plus operator.
We cannot change the precedence and associativity of any operator by operator overloading.
