Class inheritance: Function is inaccessible

You want public inheritance:

 class Weapon : Shopable

should be:

 class Weapon : public Shopable

Also, names like _SHOPABLE_H_ are illegal in user written C++ code, as they are reserved for the C++ implementation. Forget the leading underscores and use SHOPABLE_H.

And:

 Weapon(int Cost,int Damage,std::string Name)

should be:

 Weapon(int Cost,int Damage, const std::string & Name )

to avoid the unnecessary overhead of copying the string.

You might want to rethink your naming convention – typically, function parameter names in C++ begin with a lower case latter. Names beginning with uppercase letters are typically reserved for user-defined types (i.e. classes, struct, enums etc.)

As a matter of interest, which C++ textbook are you learning from?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)