0
一類我試圖將類聲明「圖形」,但在graphics.cpp,我得到的錯誤。C++創建在單獨的.cpp和.h文件
「圖形」是不是類或命名空間名稱。
它說了錯誤的位置是
圖形::圖形()
我使用Visual Studio 2010,並在我的代碼,圖形被突出顯示爲一類..但它顯然不被graphics.cpp視爲一個類?有人知道這裏有什麼問題嗎?
這裏是我的代碼
//graphics.h
#ifndef GRAPHICS_H
#define GRAPHICS_H
struct SDL_Window;
struct SDL_Renderer;
class graphics
{
public:
graphics();
~graphics();
private:
SDL_Window* _window;
SDL_Renderer* _renderer;
};
#endif
然後
//graphics.cpp
#include "graphics.h"
#include "stdafx.h"
graphics::graphics() {}
graphics::~graphics() {}
嗯,'顯卡::圖形()'應該足夠了,除非你是不是失去了一些東西在其他地方你不顯示。 –
我不能重現你的錯誤,但我沒有使用VS或SDL。嘗試從示例中刪除儘可能多的代碼,同時仍然重現錯誤,如果問題仍然不明顯,請發佈[最小完整示例](http://stackoverflow.com/help/mcve) 。 – Beta
如果你把'#ifdef來之前'的#include 「graphics.h中」 GRAPHICS_H''#錯誤test''#'endif',你得到一個錯誤說 「測試」? – immibis