I am trying to use the "win" object from the "cheese" class to access the member function "multiply()." The only error message I am getting is "struct cheese win already defined in cheese object." I don't know how to fix this and I would like to know how I would use the "win" object of "cheese" class to call member functions. I am aware that I could create an object of the class by doing:
The problem is since you are creating a cheese object called 'win' inside the header, both your main file and cheese.cpp are trying to create a 'win' object separate and so you have your error.
You can only declare the object in one source file; if other files need to use the same one they need to declare it as extern.