Reputation: 133
So I am getting this:
Error: Argument of type
"Person *"
is incompatible with type"Person *"
I have no idea what I am doing wrong. Im sure it is something stupid but if someone could point it out that would be great.
LL* g_list;
int size = 50;
char getOption();
int main()
{
char input;
bool running = true;
g_list = new LL;
char* name = new char[size];
char* color = new char[size];
cout << "enter name: ";
cin >> name;
cout << "enter color: ";
cin >> color;
Person* pers = new Person(name, color);
g_list->addBack(pers); //error
return 0;
}
//LL.cpp file (linked list)
void LL::addBack(Person* pobj)
{
if (count_ == 0)
{
head_ = pobj;
}
else
{
Person* ptr = head_;
for (int i = 0; i < count_ - 1; i++)
{
ptr = ptr->next_;
}
ptr->next_ = pobj;
}
count_++;
pobj->next_ = 0;
return;
}
//Person constructor
Person::Person(char* name, char* color)
{
name_ = new char[strlen(name)];
strcpy(name_, name);
color_ = new char[strlen(color)];
strcpy(color_, color);
next_ = 0;
}
Let me know if any more info is needed.
Upvotes: 1
Views: 90
Reputation: 28772
It seems weird as the types are reportedly the same. I can think of only one reason: you have two different Person
types and they are conflicting. You need to figure out from where the definition of Person
in main()
is coming and compare that to the definition of Person
used in LL::addBack()
Upvotes: 2