ambiguous reference error for member variable ‘name’

  ambiguous, c++, char, string

I have declared a variable name within people class which is producing ambiguity error. I tried renaming the name variable, avoided using using namespace std, imported the required libraries, replaced character array with string type but it throws same error all the time. I referred to other posts on Stackoverflow but I could not find the solution.

#include <iostream>
#include <cstdlib>
#include <cstring>


class people{
    public:
    char name[20];
};

class staff : public people {
    public:
    int i = 3; 
};

class manager : public people {
    public:
    int j = 8;
};

class lecturer : public manager, public staff {
    public:
    void set(char* a) {
        strcpy(name, a);
    }
    void get(){
        std::cout << "Lecturer name: " << name << std::endl << "Number of managers: " << j << std::endl << "Number of staff: " << i << std::endl;
    }
};

int main() {
    lecturer ob;
    ob.i = 1;
    ob.j = 6;
    ob.set("aaa bbb");
    ob.get();
    return 0;
}

and the error message is

main.cpp:24:16: error: reference to ‘name’ is ambiguous
     strcpy(name, a);

Source: Windows Questions C++

LEAVE A COMMENT