Bonjour
Je suis en train d'apprendre c++, alors pardonnez-moi de poser une question vraiment basique.
Mes questions sont:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include <iostream> #include <vector> struct t { int a; std::vector<int> b; t(int n) : a(n), b(n, 1) {} }; int main() { t x(2); //t x(2, 2); std::cout << x.a << " " << x.b[0] << " " << x.b[1]; // affiche 2 1 1 }
- Pourquoi x.b[0] affiche 2 1 1 et pas 2 2 1?
- Comment s'appelle opérateur ':' dans t(int n) : a(n), b(n, 1) {} ?
- Comment faire pour afficher 2 2 1?
Merci bien à tous!
Partager