I am creating a class to handle physics as part of a project. We were told to use a class that handles arbitrary behavior.
I created a class that will update the internal state based on the modules that are provided to it (the code follows). However, the structure representing the internal state, PhysicsData , is not recognized anywhere except in its own file. Can anyone shed some light?
(Sorry for the massive dump of information, but the gap between the object being the problem and the place where the problem is large enough and trimming the extra details also removes the context that may be useful)
Here is the structure in question:
#pragma once // This file "PhysicsBehaviourBase.h" #include <d3dx9.h> #include <vector> struct PhysicsData { public: D3DXVECTOR3 velocity; D3DXVECTOR3 position; D3DXVECTOR3 rotation; float size; PhysicsData(); void add(const PhysicsData& pd); };
All references to PhysicsData in the rest of this file are in order. However, this file begins to hint at problems:
#pragma once
In the void update(float time,const PhysicsData&, PhysicsData* out) line void update(float time,const PhysicsData&, PhysicsData* out) both links to PhysicsData receive the IntelliSense error message:
Physics PhysicsData Error: variable "PhysicsData" is not a type name.
I have no idea why IntelliSense thinks PhysicsData is a variable of type Physics . ( Physics is type I declaring the next, and PhysicsData is one of the parameters used to create the physics object).
However, there are currently no compiler errors. A compiler error occurs in the following hierarchy file:
#pragma once // "Physics.h" #include "Timing.h" #include "PhysicsBehaviours.h" #include <d3dx9.h> // For D3DXVECTOR3 #include <vector> class Physics { private: std::vector<PhysicsBehaviour*> behaviours_; Timing timer; PhysicsData data; void addBehaviours(const BEHAVIOUR_LIST&); public: Physics(const PhysicsData&,const BEHAVIOUR_LIST&); ~Physics() {} void update(); PhysicsData state() const {return data;} float age() const {return timer.age();} };
Both links to PhysicsData receive the same IntelliSense error as above. Compiler errors point to this function:
#include "Physics.h"
Compiler Errors:
1> Physics.cpp 1>[PATH]\physics.cpp(4): error C2226: syntax error : unexpected type 'PhysicsData' 1>[PATH]\physics.cpp(5): error C2065: 'initialState' : undeclared identifier 1>[PATH]\physics.cpp(6): error C2448: 'data' : function-style initializer appears to be a function definition
And more IntelliSense errors: Under & in const PhysicsData& from line 4:
Error: this declaration has no storage class or type specifier.
Under the closing bracket in line 4:
Error: expected a declaration.
Any hints, corrections or hypotheses are welcome.