Why do I get different output? How can I fix this? I want the trainingVector[0] to reference A.
vector<double> A(4,0);
vector<vector<double > > trainingVector;
A[0]=1;
trainingVector.push_back(A);
A[0]=2;
cout << A[0] << endl ;
cout << trainingVector[0][0] << endl ;
You cannot store references in STD containers, so what you ask for is impossible. If you want
trainingVectorto store a pointer toA, that’s entirely doable: