Reputation: 275
I am learning vectors and have encountered 2 errors in my code:
#include "std_lib_facilities.h"
int main()
{
std::cout << "Vector Example";
vector<int> v = {5,7,9,4,5,8};
for (int i=0; i<v.size(); ++i)
cout << v[i] << '\n';
}
Makefile:
main: booksource.cpp
g++ -std=c++11 -Wall -g booksource.cpp -o booksource
for header file please refer to http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h
First error:
/usr/include/c++/4.9/bits/locale_facets_nonio.h:1869:5: error: template-id ‘do_get<>’ for ‘String std::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const’ does not match any template declaration
messages<char>::do_get(catalog, int, int, const string&) const;
^
Second Error:
booksource.cpp: In function ‘int main()’:
booksource.cpp:5:29: error: could not convert ‘{5, 7, 9, 4, 5, 8}’ from ‘<brace-enclosed initializer list>’ to ‘Vector<int>’
vector<int> v = {5,7,9,4,5,8};
Upvotes: 1
Views: 146
Reputation: 3289
I can reproduce the second error message with 4.7.2, where std::vector
doesn't have a constructor that takes an initializer_list
. I don't know how this could happen with 4.9.
Personally, I would stay very far away from that header. I understand Stroustrup himself seems to have written it, but it basically does everything that a typical textbook would say not to do in the first chapter.
Upvotes: 1