constructor call

S

slurper

list<int> jobs
jobs.pushback(1);
jobs.pushback(2);

for ( it=jobs.begin; it!=jobs.end; it++ ) {
list <int> new_list(jobs)
do something;
new_list.push_back(3)
}

the list declaration inside the loop: will the constructor be called each
time the loop is entered?
in other words: will the new_list always be reinitialized to the jobs list?

tx
 
A

Alf P. Steinbach

* slurper:
list<int> jobs
jobs.pushback(1);
jobs.pushback(2);

for ( it=jobs.begin; it!=jobs.end; it++ ) {
list <int> new_list(jobs)
do something;
new_list.push_back(3)
}

the list declaration inside the loop: will the constructor

Copy constructor.
be called each time the loop is entered?
Yes.

in other words: will the new_list always be reinitialized to the jobs list?

Yes.


Btw., use a few more semicolons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,970
Members
47,525
Latest member
emmawilsonpark

Latest Threads

Top