A
arnuld
what i want: i want to add 6 elements to vector, beginning at 10. i mean
vector needs to have 6 elements in this order: 10, 11, 12, 13, 14, 15.
what i get: error
#include <iostream>
#include <vector>
int main()
{
const int v_size = 6;
std::vector<int> ivec(v_size); /* now, i can add any number of elelemnts */
/* adding elelemnts to vector */
/* std::vector<int>::size_type begin_vector = 10; */
int begin_element = 10;
for(std::vector<int>::iterator iter=ivec.begin(); iter != ivec.end(); ++iter)
{
*iter = ivec.push_back(begin_element++);
}
return 0;
}
======= OUTPUT ===========
/home/arnuld/programming/cpp $ g++ -ansi -pedantic -Wall -Wextra test.cpp
test.cpp: In function ‘int main()’:
test.cpp:14: error: void value not ignored as it ought to be
/home/arnuld/programming/cpp $
vector needs to have 6 elements in this order: 10, 11, 12, 13, 14, 15.
what i get: error
#include <iostream>
#include <vector>
int main()
{
const int v_size = 6;
std::vector<int> ivec(v_size); /* now, i can add any number of elelemnts */
/* adding elelemnts to vector */
/* std::vector<int>::size_type begin_vector = 10; */
int begin_element = 10;
for(std::vector<int>::iterator iter=ivec.begin(); iter != ivec.end(); ++iter)
{
*iter = ivec.push_back(begin_element++);
}
return 0;
}
======= OUTPUT ===========
/home/arnuld/programming/cpp $ g++ -ansi -pedantic -Wall -Wextra test.cpp
test.cpp: In function ‘int main()’:
test.cpp:14: error: void value not ignored as it ought to be
/home/arnuld/programming/cpp $