Im getin the following error when i try the code below..Anyone tell me whats wrong?? (name is defined in animal class)..

52 C:\Dev-Cpp\oopAssign1.cpp no match for 'operator>>' in 'std::cin >> name'

void Animal::arrayDisplay(){
     string name[3];
     cout <<"Input 3 names:" << endl;
     for(int i=0; i<3; ++i){
        cin >> name;
        name[i] = name;
        cout << "name[i]" <<endl; }

The variable "name" is an array of std::string. As such, the actual variable called "name" is a pointer to std::string. Since it's a pointer to std::string, you can't input to it directly. You need to input to an element of the name array:

std::string array[10];
for (int i = 0; i < 10; ++i) {
  cin >> array[i];

thanks for help! working now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.