Object-Oriented Programming C++ - Small Programs . This problem requires that yo
ID: 3728149 • Letter: O
Question
Object-Oriented Programming C++ - Small Programs
. This problem requires that you write a class definition, and implement two of its functions. Given the following class definition: class Base public: Base i Base (char y) char getLetter O const void setLetter (char c) private: char letter Derive a class from Base called Derived. It must have the following: Default Constructor Constructor that takes a single char Constructor that takes a single char and one int An overloaded insertion operator . A new private data member int called num Write out the class definition, and implement the constructor that takes two parameters (use the initialization section), and the insertion operator. The insertion must print the Derived object in the following way: (char, int), with the parentheses.Explanation / Answer
class Derived:public Base {
public:
Derived() {
}
Derived(char c):Base(c){
}
Derived(char c, int n):Base(c) {
num = n;
}
istream & operator >> (istream &in)
{
in >> num;
return in;
}
private:
int num;
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.