1)Write a C++ class and name it Base. The Base class has two constant private fields: one
of type string called name and one of type integer called age; and a constructor that accepts
two inputs
The Base class also has three public methods: get_name() that returns the name field,
get_age() that returns the age field, and get_info() that returns the following string (The
name is name at the age of age.)
2)-Write another C++ class and name it Derived. The Derived class inherits form the base
class. The Derived class has one private field, type, of type string, a public method,
get_type(), which returns the type, and a constructor that accepts three inputs.
The Derived class also has another public method that overrides the get_info() method,
inherited from the Base class, which returns the following string (The name is name (type)
at the age of age.)
السؤال
حمامه السلام
1)Write a C++ class and name it Base. The Base class has two constant private fields: one
of type string called name and one of type integer called age; and a constructor that accepts
two inputs
The Base class also has three public methods: get_name() that returns the name field,
get_age() that returns the age field, and get_info() that returns the following string (The
name is name at the age of age.)
2)-Write another C++ class and name it Derived. The Derived class inherits form the base
class. The Derived class has one private field, type, of type string, a public method,
get_type(), which returns the type, and a constructor that accepts three inputs.
The Derived class also has another public method that overrides the get_info() method,
inherited from the Base class, which returns the following string (The name is name (type)
at the age of age.)
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.