Main

class State {
public:
State (string stateName); // initialize with the given state’s information
int getPopulation(); // return the state’s population
};

Can I write main function code using just this or would I need to see the State class’ source file with the class definition? and would it compile?
To compile your main function, you just need what you have above; it contains all the information needed for the compiler to understand any code in the main function that uses the class.

To create an executable that you can actually run, the linker will need to link the object code created from your main function, with the object code created from the State class' source file.
Topic archived. No new replies allowed.