Advertisements
Advertisements
Question
What are the points to be noted while deriving a new class?
Solution
The following points should be observed for defining the derived class:
- The keyword class has to be used.
- The name of the derived class is to be given after the keyword class.
- A single colon.
- The type of derivation (the visibility mode), namely private, public, or protected. If no visibility mode is specified, then by default the visibility mode is considered as private.
- The names of all base classes (parent classes) separated by a comma.
APPEARS IN
RELATED QUESTIONS
Which of the following derives a class student from the base class school?
Which visibility mode should be used when you want the features of the base class to be available to the derived class but not to the classes that are derived from the derived class?
A class is derived from a class which is a derived class itself, then this is referred to as ______
What is a base class?
Why derived class is called a power-packed class?
Based on the following class declaration answer the question?
class vehicle
{ int wheels;
public:
void input_data(float,float);
void output_data();
protected:
int passenger;
};
class heavy_vehicle : protected vehicle {
int diesel_petrol;
protected:
int load;
public:
void read_data(float,float)
void write_data(); };
class bus: private heavy_vehicle {
char Ticket[20];
public:
void fetch_data(char);
void display_data(); };
The member function that can be accessed by an object of bus Class is ______
Consider the following c++ code and answer the question?
class Personal
{ int Class,Rno;
char Section;
protected:
char Name[20];
public:
personal();
void pentry();
void Pdisplay(); };
class Marks:private Personal
{ float M{5};
protected:
char Grade[5];
public: Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
public:
char FinalGrade, Commence[20];
Result();
void Rcalculate();
void Rdisplay();
};
Name the base class(/es) and derived class (/es).
Consider the following c++ code and answer the question?
class Personal
{ int Class,Rno;
char Section;
protected:
char Name[20];
public:
personal();
void pentry();
void Pdisplay(); };
class Marks:private Personal
{ float M{5};
protected:
char Grade[5];
public: Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
public:
char FinalGrade, Commence[20];
Result();
void Rcalculate();
void Rdisplay();
};
Write the names of data members accessible from the object of class Result.
Consider the following c++ code and answer the question?
class Personal
{ int Class,Rno;
char Section;
protected:
char Name[20];
public:
personal();
void pentry();
void Pdisplay(); };
class Marks:private Personal
{ float M{5};
protected:
char Grade[5];
public: Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
public:
char FinalGrade, Commence[20];
Result();
void Rcalculate();
void Rdisplay();
};
Write the names of all member functions accessible from the object of class Result.
Consider the following c++ code and answer the question?
class Personal
{ int Class,Rno;
char Section;
protected:
char Name[20];
public:
personal();
void pentry();
void Pdisplay(); };
class Marks:private Personal
{ float M{5};
protected:
char Grade[5];
public: Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
public:
char FinalGrade, Commence[20];
Result();
void Rcalculate();
void Rdisplay();
};
Write the names of all members accessible from member functions of class Result.