188k views
1 vote
"write a short c++ program that creates a pair class that can store two objects declared as generic types."

User Gelmir
by
7.8k points

1 Answer

0 votes

Strictly speaking, the c++ program does not create a Pair class, but instantiates a Pair object that can store two objects as declared as generic types. Is that what you meant? (Otherwise you're looking at static members which doesn't make sense for a pair class).

class Pair

{

public:

int number;

double factor;

};



int main()

{

Pair A;

A.number = 42;

A.factor = 2.6;

return 0;

}


User Uberwach
by
9.1k points