I have some code where I'm pushing objects onto a vector using push_back(). The class is counting how many times the object is being copied and I'm displaying the copy total after each push_back(). Not knowing anything about how push_back() is implemented I was just curious as to why the copy totals amass like this: 1, 3, 6, 7, 12, 13, 14, 15, 24, 25? I'm especially curious about the jump from 1 to 3 after the second push_back().
The code in question is simply:
Code:
while (read(in, record))
{
students.push_back(record);
Student_info::show_info(); // prints copy total
cout << endl;
}
The read() function doesn't make any copies.