Invalid conversion problem

I've been having this bug for a couple of hour and I don't know what to try else.

I have these two lines:

1
2
std::vector<std::vector<std::string> > menus_;
menus_[0][0].push_back("test");


and the G++ compiler(I'm on linux) gives me this error:

main.cpp: In function ‘int main()’:
main.cpp:9: error: invalid conversion from ‘const char*’ to ‘char’
main.cpp:9: error: initializing argument 1 of ‘void std::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’
make: *** [main.o] Error 1

The main.cpp:9 (line 9) is the line with the push_back.

I just don't understand why it tells me invalid conversion. I have a vector of vector of string, and it's exactly what I try to pass with the push_back.

I know it's probably a very simple thing but I've searched all over my books on c++ and they all tell me that these two lines should be ok!
It goes like this:

1
2
3
4
std::vector<std::vector<std::string> > menus_;
std::vector<std::string> x;
x.push_back("test");
menus_.push_back(x);


or

1
2
3
std::vector<std::vector<std::string> > menus_;
menus_.push_back(std::vector<std::string>());
menus_[0].push_back("test");
Last edited on
Right, I knew it was a simple mistake.

Thanks
Topic archived. No new replies allowed.