Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement in C++ the code for an Any-Type class with the following private data members: data type AT named item Boolean defined to

Design and implement in C++ the code for an Any-Type class with the following private data members:

data type AT named item

Boolean defined to indicate if the item has been set

The class should also have the following public member methods:

a default constructor that initializes defined to false.

a getItem method that tests to see whether item has been set, and if it has returns the value of item. If it has not, the method displays a message that the item has not been set.

a setItem method that assigns the parameter the value to item and sets defined to true.

Write a C++ program to test your class AnyType. Your program should create five objects of template class AnyType.

Store an integer type in object ATint, a character type in object ATchar, a string type in object ATstring, double type in object ATdouble, float type in object ATfloat and a boolean type in object ATbool.

Your program should then test the setItem method with the values 4,'A',"Hello World C++",5.5f,17.2 and false.

Then call the getItem method to show the values of each object.

The following is a copy of the screen results that should appear after running your program:

The value of ATint is: 4 The value of ATchar is: A The value of ATdouble is : 17.2 The value of ATfloat is: 5.5 The value of ATstring is: Hello World C++ The value of ATbool is: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions