| | |
iterator problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 630
Reputation:
Solved Threads: 46
I would expect this to ouput the 5 doubles, but instead I get the output below.
Any ideas why?
Thanks,
Dave
C++ Syntax (Toggle Plain Text)
vector<double> a(5); a.push_back(1.2); a.push_back(1.3); a.push_back(1.4); a.push_back(1.5); a.push_back(1.6); vector<double>::iterator i; i = a.begin(); while( i != a.end() ) { cout << *i << endl; i++; }
C++ Syntax (Toggle Plain Text)
0 0 0 0 0 1.2 1.3 1.4 1.5 1.6
Any ideas why?
Thanks,
Dave
>>vector<double> a(5);
That creates an array of 5 doubles.
>> a.push_back(1.2);
That adds an additional element to the array, so after this line executes the array will have 6 elements.
That creates an array of 5 doubles.
>> a.push_back(1.2);
That adds an additional element to the array, so after this line executes the array will have 6 elements.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Need help writing my own reverse iterator class (C++)
- Re-Worked Version Still problem !!! (Java)
- "cannot resolve symbol"problem (Java)
- List <char *> Problem (C)
- Problem While Processing A String List (C++)
- Problem with pointers (C++)
Other Threads in the C++ Forum
- Previous Thread: Space/tabular problem after reading file to array
- Next Thread: command time output in Linux
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






