Hi, I need to make a text-base video game for collage. There has to be a class character but I am having an error message:
Class_Character.h:36: error: no match for 'operator<<' in 'os << char1.character::give_race'
this is my header file for the class character:
#ifndef CHARACTER
#define CHARACTER
#include <iostream>
#include <string>
class character
{
friend std::ostream& operator<<(std::ostream&, character);
public:
std::string give_race();
int give_STR();
int give_CON();
int give_DEX();
int give_CHA();
void set_race(string);
void set_properties ();
void save_race();
private:
std::string race;
int STR;
int CON;
int DEX;
int CHA;
int throw_dices_for_properties();
};
inline std::ostream& operator<<(std::ostream& os, character char1) {
return os << char1.give_race;
}
#endif
If you guys know what is wrong with it plz chare :d!
The only problem I see is that you are not trying to print a string, but a pointer to a function that has void parameters and returns std::string. Change return os << char1.give_race; into return os << char1.give_race();