Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c++, #include #include flex.h using namespace std; int main() { Flex a, b(123), c(64374924); cout < < a < < ',' < < b
In c++,
#include#include "flex.h" using namespace std; int main() { Flex a, b(123), c(64374924); cout << a << ',' << b << ',' << c << endl; b.cat(a); cout << b << endl; b.cat(c); cout << b << endl; c.cat(c); c.cat(c); cout << c << endl; return 0; } Here is my execution output: *0*,*123*,*64374924* *123 * *123 64374924* *64374924643749246437492464374924*
I was wondering if this was possible to do. There has to be a cat
- Objects of class Flex allow a variable length int to be maintained. - When the constructor for Flex is provided an int as a parameter, the Flex object created will have that int value. If no parameter is provided, a default int (0) should be created. - Flex should have an overload of the output operator (<<) that will display the int surrounded by stars (*). - Flex also has a void function, cat, having one reference parameter of type Flex. The function cat should append the parameter to the end of the Flex object invoking cat. - There is no established bound on the size of a Flex object, so dynamic storage allocation should be used. - All Flex member data is private
I was wondering if this was possible to do and if so, how would the flex.h and flex.cpp look like.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started