I am trying to create a modular program. In one module (clss.cpp) I have a class (named score). How do I access it from my main.cpp file. The keyword "extern" only works for functions and variables (My make file links both files correctly).
code:
clss.cpp
class score
{
private:
int points;
public:
int show_money(void) {return (points);}
score();
};
inline score::score()
{
int points=1000;
}
main.cpp
using namespace std;
extern class score;
int main()
{
score points;
cout<< "Score:" << points::show_money() << "\n";
//system("PAUSE"
return (0);
}
I get an error stating that extern can only be used for functions and variables. So how do I reference a class in another module (or file)? Any help would be greatly appreciated.
code:
clss.cpp
class score
{
private:
int points;
public:
int show_money(void) {return (points);}
score();
};
inline score::score()
{
int points=1000;
}
main.cpp
using namespace std;
extern class score;
int main()
{
score points;
cout<< "Score:" << points::show_money() << "\n";
//system("PAUSE"
return (0);
}
I get an error stating that extern can only be used for functions and variables. So how do I reference a class in another module (or file)? Any help would be greatly appreciated.