- Define a class FLIGHT in C++ with following description:
Private Members:
- A data member Flight number of type integer
- A data member Destination of type string
- A data member Distance of type float
- 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 FEEDINFO() to allow user to enter values for Flight Number,
Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel
- " A function SHOWINFO() to allow user to view the content of all the data members
-
Answer the questions (i) to (iv) based on the following:
class CUSTOMER
{
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
};
class SALESMAN
{
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
};
class SHOP : private CUSTOMER , public SALESMAN
{
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
};
- Write the names of data members which are accessible from objects belonging to class CUSTOMER.
- Write the names of all the member functions which are accessible from objects belonging to class SALESMAN.
- Write the names of all the members which are accessible from member functions of class SHOP.
- How many bytes will be required by an object belonging to class SHOP?
- Write a function in C++ to count the number of lines present in a text file "STORY.TXT".
- Given a binary file PHONE.DAT, containing records of the following structure type.
class Phonlist
{
char Name[20] ;
char Address[30] ;
char AreaCode[5] ;
char phoneNo[15] ;
public :
void Register();
void show();
int CheckCode(char AC[ ])
{
return strcmp(Areacode, AC) ;
}
} ;
Write a function TRANSFER () in C++, that would copy all those records which are having AreaCode as “DEL” from PHONE.DAT to PHONBACK.DAT.
- Give one advantage of function overloading with default arguments
- Differentiate between object oriented programming and procedural programming
- What do you understand by Copy constructor? Specify two instances when copy constructor is invoked?
- Differentiate between containership and inheritance with example.