Why am I getting string does not name a type Error?

前端 未结 5 1877
Happy的楠姐
Happy的楠姐 2020-11-29 19:02

game.cpp

#include 
#include 
#include 
#include \"game.h\"
#include \"         


        
5条回答
  •  我在风中等你
    2020-11-29 19:36

    string does not name a type. The class in the string header is called std::string.

    Please do not put using namespace std in a header file, it pollutes the global namespace for all users of that header. See also "Why is 'using namespace std;' considered a bad practice in C++?"

    Your class should look like this:

    #include 
    
    class Game
    {
        private:
            std::string white;
            std::string black;
            std::string title;
        public:
            Game(std::istream&, std::ostream&);
            void display(colour, short);
    };
    

提交回复
热议问题