-2

I am getting the error "string does not name a type" despite having the "using namespace std;" in the program.

#ifndef SHAPE_H
#define SHAPE_H

using namespace std;

class Shape
{
    public:
        Shape();
        virtual ~Shape();
        string getShapeName();
        void setShapeName(string shapeName);
        virtual float calculateArea() = 0; //Calculates area of the shape
    protected:
        const float PI = 3.14159265;
    private:
        string m_ShapeName;

};

#endif // SHAPE_H_INCLUDED
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • 6
    You missed to `#include `. And please don't use `using namespace std;` especially not in header files. – πάντα ῥεῖ May 27 '17 at 16:05
  • 1
    Hi @πάντα ῥεῖ, thank you very much for the advice, I made the changes as per the advice and program is compiling.Can you please elaborate, as to why it is a bad idea to use namespaces? – user1128033 May 27 '17 at 18:09
  • Sure: https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice – πάντα ῥεῖ May 27 '17 at 18:10

1 Answers1

1

You are missing the <string> header:

#include <string>
Mureinik
  • 297,002
  • 52
  • 306
  • 350