I've been using code::blocks for I don't know how long and it's always worked just fine. All of a sudden it started throwing this "error: in C++98 'myVector' must be initialized by constructor, not by '(...)'".
I wish I knew why it was talking about C++98 instead of C++11. If anyone can lend me some insight, I'd greatly appreciate it.
GCC still use C++98 by default. You can enable C++11 by passing -std=c++0x (or -std=c++11 in gcc 4.7). Note that no compiler have complete support for C++11 yet.
As coder777 says, we can't help you unless you show some code.
#include <string>
#include <vector>
#include <iostream>
usingnamespace std;
int main()
{
vector<string> myVector = {"A first string", "A second string"};
// adding some vectors using push_back
myVector.push_back("A third string");
myVector.push_back("The last string in the vector");
// iterate over the elements in the vector and print them
for (auto iterator = myVector.cbegin();
Iterator != myVector.cend(); ++iterator) {
cout << *iterator << endl;
}
// print the elements again using C++11 range-based for loop
for (auto& str : myVector)
cout << str << endl;
return 0;
}
After fixing the typo in line 13, this program compiles with gcc 4.6.2
$ g++ -W -Wall -Wextra -pedantic -O3 -march=native -std=c++0x -o test test.cc
~ $ ./test
A first string
A second string
A third string
The last string in the vector
A first string
A second string
A third string
The last string in the vector