which of the following declacation would be permissible type

which of the following declacation would be permissible type instantiation in C++, assuming that aBox class took a single type parameter?

1- Box <int> myBox;

2- Box <PayrollRecord> myBox;

3- Box<3> myBox;

4- Box< int *> myBox;

5- Box< PayrollRecord *> myBox;

6- Box< PayrollRecord > *myBox;

7- Box<> myBox;

8- Box myBox;

-The answers are more than one

Solution

Since the Box class takes a single type parameter.

1- Correct since during declaration only one data type is provided to the class

2- Correct since during declaration only one data type is provided to the class, PayrollRocord is the data in the class definition.

3- InCorrect since 3 is not a data type

4- InCorrect since during declaration a series of data type int is provided to the Box class but the class only takes one input type parameter

5- InCorrect since during declaration a series of data type PayrollRecord is provided to the Box class but the class only takes one input type parameter

6- Correct since during declaration , single parameter PayrollRecord is provided is provided to the Box class and a series of boxes are declared with same data type using *myBox.

7- Incorrect as No data type is provided to the class during declaration

8- InCorrect as No data type is provided to the class during declaration

 which of the following declacation would be permissible type instantiation in C++, assuming that aBox class took a single type parameter? 1- Box <int> my

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site