-3

here is the code

#include <iostream>
#include <string>
#include "char.h"
#include "user.h"

bool user::readYN (string ans)
{
    ans = tolower (ans);
    if (ans == "y" || ans == "yes")
    {
        return true;
    }
    else if (ans == "n" || ans == "no")
    {
        return false;
    }
    else 
    {
        std::cout<<playr.inputErr;
        return false;
    }
}

The string ans is passed to it from my main.cpp and should be a y\n to confirm a charecter name. However whenever I try to compile this I get the error

user.cpp:6: parse error before '{'

and the errer

user.cpp:8: parse error before '+'

I have no idea where it is getting an error for the { and I don't know where it see's a +(my thinking is the equal... maybe???) All my other code has compiled and I just want to start actually building stuff.

EDIT: By request the header files are as follows

user.h

#ifndef user
#define user

#include<string>
class user
{
    public:
        string input;
        static string inputErr;
        bool readYN(string);
        void read(string);

}playr;

#endif

and char.h

#ifndef chara
#define chara

#include<string>
class charecter
{
    public:
        string name;
        bool yes;
        int HP;
        void nameMe(string);
}chara;

#endif
ArtoriusIV
  • 9
  • 1
  • 6

2 Answers2

0

Change

bool user::readYN (string ans)

to

bool user::readYN (std::string ans)
Happy Green Kid Naps
  • 1,611
  • 11
  • 18
0

Issue resolved. The defining in user.h screwed with the class declaration.

ArtoriusIV
  • 9
  • 1
  • 6
  • It's always good to use a naming convention for the `#include` guard macros that makes sure that it doesn't conflict with the name of class.. E.g. `USER_H` or `USER_HEADER`. – R Sahu Aug 18 '15 at 23:16