Difficile
Consider a class MyType which defines a public function isType() as:
int isType (MyType& obj)
{
return (&obj == this) ? 1 : 0;
}
What is the output of the following? Object ‘obj’ of MyType is allocated statically and a pointer variable ‘objptr’ of type MyType is declared.
objptr = &obj;
if ( objptr->isType(obj) )
std::cout << "&obj and invoking object match!!!" << std::endl;
else
std::cout << "&obj and invoking object do not match!!!" << std::endl;
Auteur: Abha AgrawaStatut : PubliéeQuestion passée 479 fois
Modifier
2
Évaluations de la communautéPersonne n'a encore évalué cette question, soyez le premier !
1
Quel est le résultat du code suivant ? #define CONSTANT 10; int main() { return CONSTANT; }3
C++ est un langage de programmation général. Il a été développé dans les années 1970 par Bjarne Stroustrup aux laboratoires Bell.3
Écrire une fonction C++ qui retourne la somme de deux entiers.2
Écrire un programme C++ qui crée un tableau de 10 objets Person.1
Quelle est la finalité d'une méthode statique en C++?2
Quelle est la valeur de p1 et q1 dans le code suivant ?
```c++
int i = 0;
int *p = &i;
int *const p1 = &i;
int *const q1 = &*p;
```1
Qu'est-ce que les templates en C++?