Nov 1, 2016 at 6:01pm UTC
I am trying to use a string so I can add a persons name but i keep getting an overload error?
1 2 3 4
class Character
{
public :
Character(string Name);
It works when its an int but not a string , any ideas to why this may be?
Last edited on Nov 1, 2016 at 10:22pm UTC
Nov 1, 2016 at 6:11pm UTC
Have you #included the proper header file to use the string class? How are you scoping the string class to the std namespace?
Nov 1, 2016 at 6:12pm UTC
How are you passing the string to the constructor?
Nov 1, 2016 at 6:16pm UTC
Also what other constructors do you have for your class?
Nov 1, 2016 at 6:25pm UTC
Character::Character(string Name);
Is that how it is passed to the constructor. Only learnt it last week.
Nov 1, 2016 at 6:25pm UTC
What is the full text of the error?
Nov 1, 2016 at 6:30pm UTC
Please post a small complete program. It looks like you're confusing constructors with "setter" functions.
Nov 1, 2016 at 6:43pm UTC
This is all I have of the program I am working on.
[code]
#include <iostream>
#include <string>
using namespace std;
class Character
{
public:
Character(string Name);
string GetName();
Character(int Age);
int GetAge()const;
Character(char Sex);
char GetSex;
Character(int ExperienceLevel = 0);
int GetExperienceLevel() const;
Last edited on Nov 1, 2016 at 10:23pm UTC
Nov 1, 2016 at 7:10pm UTC
Im going to start over again, see if I can work it out fresh and not have to work through all this mess.
So I cant have two ints?
Nov 1, 2016 at 7:21pm UTC
Oh i missread what you wrote, Just noticed you said parameters.