Pointers
Was gibt folgendes Programm aus?
#include <iostream>
int main() {
int a = 5;
int* b = &a;
std::cout << b;
return 0;
}Optionen: Wert von a, Wert von b, Adresse von a, kompiliert nicht.
Korrekt: Wert von b, Adresse von a
Was gibt folgendes Programm aus?
#include <iostream>
int main() {
int a = 5;
int* b = &a;
int& c = *b;
std::cout << c;
return 0;
}Optionen: Wert von a, Wert von b, Adresse von b, kompiliert nicht.
Korrekt: Wert von a
Was gibt folgendes Programm aus?
#include<iostream>
#include<vector>
int main() {
int a = 5;
int* b = &a;
unsigned int* c = b;
std::cout << c;
return 0;
}Optionen: Wert von a, Wert von b, Adresse von b, kompiliert nicht.
Korrekt: kompiliert nicht.
Was gibt folgendes Programm aus?
#include<iostream>
#include<vector>
int main() {
int a = 5;
int* b = &a;
int* c = &b;
std::cout << c;
return 0;
}Optionen: Wert von a, Wert von b, undefiniertes Verhalten, kompiliert nicht.
Korrekt: kompiliert nicht.
Was gibt folgedes Programm aus?
#include<iostream>
#include<vector>
int main() {
int a = 5;
int* b = &a;
int* c = b+5;
std::cout << *c;
return 0;
}Optionen: Wert von a, Wert von b, undefiniertes Verhalten, kompiliert nicht.
Korrekt: undefiniertes Verhalten
Was gibt folgendes Programm aus?
#include<iostream>
#include<vector>
void foo(int* f, int* h){
int tmp = *f;
*f = *h;
*h = tmp;
}
int main() {
int a = 6;
int b = 2;
int* c = &a;
int* d = &b;
foo(c,d);
std::cout << a;
return 0;
}Antwort: 2