Question du test C++

Quel est le résultat du code C++ suivant ?

Intermédiaire

What is the output of the following code:

template <class T>
class MyPair
{
T first, second;
  public:
    		MyPair(T v1, T v2)
  {
            	    	first=v1;
            	    	second=v2;
    		 }
 T valueOfTwo();
 
};
 
template <class T>
T MyPair<T>::valueOfTwo()
{
    		return first>second? first : second;
}

Assume that ‘int’ is passed as an argument to class template MyPair and an object obj is created from the class template MyPair by invoking its two arguments constructor using the actual parameters 30 and 40. What would be the result of the call obj.valueOfTwo();

Auteur: Abha AgrawaStatut : PubliéeQuestion passée 377 fois
Modifier
1
Évaluations de la communautéPersonne n'a encore évalué cette question, soyez le premier !