Problem retrieving object from a vector

Hello, I have two versions of a code which basically draws a "note" object in the screen.

Code1:
1
2
Note n1(string("Texture/note1.png"), 35, 1, 4);
renderer->drawSprite(n1.getTexture()->getID(), 64,128, n1.getXPos(), n1.getYPos(), 24,8,19,1)


Code2:
1
2
3
4
5
std::vector<Note> notes[1];
notes[0].push_back(Note(string("Texture/note1.png"), 37, 5, 2));

Note temp = notes[0].at(0);
renderer->drawSprite(temp.getTexture()->getID(), 64,128, temp.getXPos(), temp.getYPos(), 24, 8, 19,1);



The first version works just fine but the second one doesn't. Am I doing something wrong with the 2nd version?
Depends on the copy constructor and the assignment operator of the class Note.

The main difference between the codes is that the first one doesn't use copy construction or assignment, while the second code does.

If you have provided code for the copy constructor or the assignment operator, then show it.
webJose:
Depends on the copy constructor and the assignment operator of the class Note.

The main difference between the codes is that the first one doesn't use copy construction or assignment, while the second code does.

If you have provided code for the copy constructor or the assignment operator, then show it.


I'm new to C++ (you can I assume that I don't have any idea about copy constructors and overloading of the assignment operator). Could you help me fix the 2nd version of my code? Thanks!
Since I am not too familiar with animation, it would be best for you to learn about copy constructors and assignment operators. Read the tutorial in this site, and if not clear enough, read others found in the Internet.

If you have specific questions about what you learn, you can come back and post those more specific questions.

http://www.cplusplus.com/doc/tutorial/classes/
Topic archived. No new replies allowed.