Reference no: EM132194475
Write a C++ program A3p2.cpp with a class of your own design.
The class should contain a protected int variable var, which is initialized with an integer value between 1 and 50 in a constructor.
The class should contain a public member function called play that should print out a sequence of integers as a result of iteratively applying a function f to the integer var. The function f is defined as f(x)=3x+1 if x is odd and f(x)=x/2 if x is even.
Stop the iteration when the value 1 is reached. (Example: When var is 6, the play function's output sequence should be 6,3,10,5,16,8,4,2,1.)
In your main function create an object of this class whose member var should be initialized with a value on the command line argument (that is, argv[1]) and then call the play member function to output the sequence of desired integers.