-1

Error messages: Display::Display = Display does not name a type, Member declaration not found,Type 'std::string' could not be resolved, add a breakpoint

Display::~Display = Display does not name a type, Member declaration not found, add a breakpoint

I've looked at other "does not name type" question on stack but most of them were due to misplacing, example: "does not name a type" error

I don't really think I misplaced anything considering it's only 1 header file but maybe I overlooked something? Any help would be appreciated

display.h

#ifdef DISPLAY_H
#define DISPLAY_H

#include <string>

class Display{
          public:
                Display(int width, int hight, const std::string& title);
                virtual ~Display();
         protected:
         private:
                Display(const Display& other){}
                Display& operator = (const Display& other){}
       };
 #endif

display.cpp

#include "project\display.h"
#include <iostream>

Display::Display(int width, int hight, const std::string& title){}
Display::~Display(){}
Community
  • 1
  • 1
user7839375
  • 31
  • 2
  • 7

1 Answers1

4

Replace:

#ifdef DISPLAY_H
// ...
#endif

with:

#ifndef DISPLAY_H
// ...
#endif

Your compiler basically sees Display.h as an empty file, because DISPLAY_H is not defined, and #ifdef skips out the whole class declaration in the header file.

Dean Seo
  • 5,486
  • 3
  • 30
  • 49