Assignment - Classes AND Objects XII CS
Q1. Differentiate between public & private visibility modes in context of Object Oriented Programming using suitable examples.
Q2. What do you understand by a member function? How does a member function differ from an ordinary function?
Q3. What are the advantages and disadvantages of inline functions.
Q4. What are static class members?
Q5. Rewrite following code after removing syntax errors.UNderline each correction.
class TRAIN{
long TrainNo;
Char Description[25];
public: void Entery(){
cin>>TrainNo; gets(DEscription); }
void Display(){
cout<<TrainNo<<":"<<Description<<endl;
}
};
void main(){
TRAIN T;
Entry.T();
DIsplay.T();
}
Q6. Define a class Flight in C++ with the following specification:
Private Members:
• A Data Member Flight Number of type integer
• A Data Member Destination of type String
• A Data Member Distance of Float Type
• A Data Member Fuel of type float
A Member Function CalFuel( ) to calculate the value of fuel as per the following criteria:
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
more than 2000 2200
Public Members:
• A function Feed_Info( ) to allow user to enter values for Flight Number, Destination,
Distance & Call Function CalFuel( ) to calculate the quantity of fuel.
A Function Show_Fuel( ) to allow user to view the content of all the data members.
Q2. What do you understand by a member function? How does a member function differ from an ordinary function?
Q3. What are the advantages and disadvantages of inline functions.
Q4. What are static class members?
Q5. Rewrite following code after removing syntax errors.UNderline each correction.
class TRAIN{
long TrainNo;
Char Description[25];
public: void Entery(){
cin>>TrainNo; gets(DEscription); }
void Display(){
cout<<TrainNo<<":"<<Description<<endl;
}
};
void main(){
TRAIN T;
Entry.T();
DIsplay.T();
}
Q6. Define a class Flight in C++ with the following specification:
Private Members:
• A Data Member Flight Number of type integer
• A Data Member Destination of type String
• A Data Member Distance of Float Type
• A Data Member Fuel of type float
A Member Function CalFuel( ) to calculate the value of fuel as per the following criteria:
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
more than 2000 2200
Public Members:
• A function Feed_Info( ) to allow user to enter values for Flight Number, Destination,
Distance & Call Function CalFuel( ) to calculate the quantity of fuel.
A Function Show_Fuel( ) to allow user to view the content of all the data members.