Question: Write a class VerySilly that extends Silly. It should store a double value in addition to the information stored by Silly. It should have: a
Write a class VerySilly that extends Silly. It should store a double value in addition to the information stored by Silly. It should have:
a constructor: VerySilly(int, string, double) that sets x and s from Silly to be the int and string and stores the double itself.
a functionprintDouble that prints the double that is being stored.
code:
#include
using namespace std;
class Silly { protected: int x; private: string s; public: Silly(string sValue) { s = sValue; }
void printData() { cout << x << " " << s << " "; } };
//Do not modify anything on or above the line below this //YOUR_CODE_BELOW
//YOUR_CODE
//YOUR_CODE_ABOVE //Do not modify anything on or below the line above this
int main() { cout << fixed << setprecision(1);
VerySilly v1(4, "five", 6.0);
v1.printData(); v1.printDouble(); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
