unknown override specifier error while constructing a tree with pointer solved


I am comsidering the below example to explain this issue. I am defining a class "Terrain" and including a "Mesh" class in the Terrain class. Please find below the code snippet of Terrain class.
// Terrain.h #pragma once #include "Noise.h" #include "Mesh.h" class Terrain { public: Terrain(float width, float depth, int numVerticesW, int numVerticesD); ~Terrain(); float GetHeight(float x, float z); void Draw(); private: Mesh mMesh; Noise mNoiseGenerator; std::vector<float> mHeights; void CreateTerrain(float width, float depth, int numVerticesW, int numVerticesD); float ComputeHeight(float x, float z, float startFrequency, float startAmplitude, float persistence, int octaves); };
And the code snippet for Mesh class is:
// Mesh.h #pragma once #include <d3d11.h> #include <vector> #include "Game.h" class Mesh { public: Mesh(); ~Mesh(); template <typename T, unsigned int N> void LoadVertexBuffer(T data[][N], unsigned int size, bool dynamic = false); void LoadIndexBuffer(std::vector<unsigned int> indices); void SetVertexCount(unsigned int vertexCount); void Bind(); void Draw(); private: std::vector<ID3D11Buffer*> mVertexBuffers; std::vector<unsigned int> mStrides; ID3D11Buffer *mIndexBuffer; unsigned int mVertexCount; }; template <typename T, unsigned int N> void Mesh::LoadVertexBuffer(T data[][N], unsigned int size, bool dynamic) { D3D11_BUFFER_DESC bufferDesc = {}; bufferDesc.Usage = dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_IMMUTABLE; bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; bufferDesc.ByteWidth = sizeof(T[N]) * size; bufferDesc.CPUAccessFlags = dynamic ? D3D11_CPU_ACCESS_WRITE : 0; bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA bufferData = {}; bufferData.pSysMem = data; ID3D11Buffer *buffer; Game::GetInstance()->GetDevice()->CreateBuffer(&bufferDesc, &bufferData, &buffer); mVertexBuffers.push_back(buffer); mStrides.push_back(sizeof(T[N])); }
While compiling the code, we get the error "unknown override specifier". This is due to circular inclusion. To resolve this, add #include Terrain.h in Terrain.cpp. Please find below the code snippet:
// Terrain.cpp #include "Terrain.h" #include "Terrain.h"
The following inclusion tree works:Terrain.h --> Mesh.h --> Game.h --> Renderer.h --> Terrain.h

Solution Worked 2 UpvotesUpvote


Solution Didn't Worked 1 DownvotesDownvote



Play 2048 Game Online

Search Tags