Page 125 - C++
P. 125
Members in private visibility mode are not This is same as private visibility mode
accessible to the objects of class. They are when we consider for a class.
only accessible inside the class to the For inheritance it can be inherited.
member functions of the class. During
inheritance it cannot be inherited.
b) Answer the questions (i) & (ii) after going through the following class . 2
class travel
{
int pcode;
char place[20];
float charges;
public:
travel() // function 1
{ pcode=1;
strcpy( place, “DELHI”);
charges=1000;
}
void travelplan( float c ) // function 2
{
charges=c;
cout<<pcode<<”:”<<place<<”:”<<charge<<endl;
}
~travel() // function 3
{
cout<<” Travel Plan Cancelled “;
}
travel(int pc, char p[], float c) // function 4
{ pcode=pc;
strcpy( place, p);
charges=c;
}
};
i) In object Oriented Programming, what are FUNCTION 1 and FUNCTION 4
combined together referred as?.
Ans: Polymorphism/ constructor overloading/ function overloading/
default and parameterized constructor
ii) In object Oriented Programming, Which concept of OOPS is demonstrated
using FUNCTION 3? When is this function called/invoked?
Ans: Destructor. It is invoked when an object of a class goes out of scope.
c) Define a class BUS with the following specifications: 4
Private members:
XII / Comp. Sc. Page 4 of 17