Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone please help. This program says \"Error: pointer to imcomplete class

ID: 3757751 • Letter: C

Question

Can someone please help. This program says "Error: pointer to imcomplete class types is not allowerd" under every s1 and s2 in the last if statement in the program

#include <iostream>

using namespace std;

void main()

{

struct phone

{

int country;

int area;

int number;

};

struct phone newPhone, *structPointer;

structPointer=&newPhone;

newPhone.country=1;

(*structPointer).country=1;

(*structPointer).area=888;

(*structPointer).number=5551212;

}

int ShallowCompare(struct phone *s1, struct phone *s2)

{

if(s1==s2)

return 0;

else

return 1;

}:

int DeepCompare(struct phone *s1, struct phone *s2)

{

if((s1->country==s2->country)&&(s1->area==s2->area)&&(s1->number==s2->number))

return 0;

else

return 1;

}

Explanation / Answer

#include <iostream>

using namespace std;

struct phone

{

int country;

int area;

int number;

};

int ShallowCompare(struct phone *s1, struct phone *s2)

{

if(s1==s2)

return 0;

else

return 1;

}

int DeepCompare(struct phone *s1, struct phone *s2)

{

if((s1->country==s2->country)&&(s1->area==s2->area)&&(s1->number==s2->number))

return 0;

else

return 1;

}

int main()

{

struct phone newPhone, *structPointer;

structPointer=&newPhone;

newPhone.country=1;

(*structPointer).country=1;

(*structPointer).area=888;

(*structPointer).number=5551212;

}

Struct phone user defined type should be declared globally not locally.