I am using Code::Blocks 10.05 on Mint 11. For some reason, with the following code, I am not able to compile. If I comment out the C++11 range based for loop, it works fine aside from only giving me the output of the vector once.
Code:
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main(){
vector<string> myVector = {"A first string", "A second string"};
myVector.push_back("A third string");
myVector.push_back("The last string in the vector");
for(auto iterator = myVector.cbegin(); iterator != myVector.cend(); ++iterator)
cout << *iterator << endl;
for(auto& str : myVector)
cout << str << endl;
return 0;
}
Output is as follows:
Quote:
/home/ciphermagi/OOP/*** |In function âint main()â:|
/home/ciphermagi/OOP/*** |13|error: expected initializer before â:â token|
/home/ciphermagi/OOP/*** |15|error: expected primary-expression before âreturnâ|
/home/ciphermagi/OOP/*** |15|error: expected â;â before âreturnâ|
/home/ciphermagi/OOP/*** |15|error: expected primary-expression before âreturnâ|
/home/ciphermagi/OOP/*** |15|error: expected â)â before âreturnâ|
||=== Build finished: 5 errors, 0 warnings ===|
|
I have also attempted to use the following without success:
Code:
shared_ptr<int> myInt(new int);
Resulting in:
Quote:
/home/ciphermagi/OOP/*** ||In function âint main()â:|
/home/ciphermagi/OOP/*** |8|error: âshared_ptrâ was not declared in this scope|
/home/ciphermagi/OOP/*** |8|error: expected primary-expression before âintâ|
/home/ciphermagi/OOP/*** |8|error: expected â;â before âintâ|
||=== Build finished: 3 errors, 0 warnings ===|
|
I'm feeling like the whole C++11 library isn't installed, but I haven't been able to find a way to get a compiler that goes past GCC 4.5. Any suggestions?