In C++ you could do:
class Person{
public:
int ID;
char* name;
void Display(){
cout << "Person " << name << " ID: " << ID << endl;
}
}
Where the member function can access other variables in a class, is there anyway to do the same with a struct in C?
struct.thispointer to provide access to the members of the instance of the class. You’ll have to simulate that (or, rather,this) in your C code.