I have a problem with the vector of shared_ptrS. My code is :
//--------scoala.h--------
class Scoala
{
public:
Scoala(std::string );
int adaugaElev(std::shared_ptr<Elev> elev);
private:
std::vector<std::shared_ptr <Elev>> __elevi;
};
//-----------scoala.cpp-----------------------------
int Scoala::adaugaElev(std::shared_ptr<Elev> elev)
{
__elevi.push_back(elev);
return __elevi.size() - 1;
}
I run it and I got this "Unhandled exception at 0x0137b559 in elev.exe: 0xC0000005: Access violation reading location 0xcccccd0c". What's wrong ?
__eleviis illegal in C++ user code, as are all names that contain double underscores or start with an underscore and an uppercase letter. You also need to post the code that calls your function, and to investigate the concept of references. - user2100815{ }button in the text editor to format your code. You get better answers when your question is readable. - jalfshared_ptr's? The location in the message looks very much like an uninitialized pointer plus an offset. - Bo Persson