Write your question here.
Hi everyone
I write like this
vector<char> names;
vector<int> radii;
names.push_back("Mercury");
radii.push_back(2440);
and have error
C++ class "std::vector<char, std::allocator<char>>" has no member "push_back"
and
C++ class "std::vector<char, std::allocator<char>>" has no member "push_back"
#include <iostream>
#include <vector>
#include <string>
usingnamespace std;
int main()
{
vector<char> names;
names.push_back("Mercury"); // <==== THIS WILL FAIL
// Now COMMENT THE ABOVE LINE OUT leaving just the following ...
vector<string> moreNames;
moreNames.push_back("Mercury");
// Notice the difference?
// vector<char> or vector<string>
}