#include <iostream>
class ObjectInfo{
private:
static float Rotation;
public:
//sets object rotation value
void SetR(float a){ static float Rotation = a; }
//print roation value (I think this is where the problem is located)
void PrintR(){ std::cout << Rotation;}
};
int main()
{
ObjectInfo Wall;
//set float var
float Rotation;
//Get user set rotation
std::cin >> Rotation;
//set wall rotation
Wall.SetR(Rotation);
//print wall rotation value
Wall.PrintR();
std::cin >> Rotation;
}
Error 1 error LNK2001: unresolved external symbol "private: static float ObjectInfo::Rotation" (?Rotation@ObjectInfo@@0MA)
Error 2 error LNK1120: 1 unresolved externals
This is a protype i made and i have no clue how to resolve the error.
Does anynyone know what could cause this error?
I get the same error if i try returning the value and then couting that value.
Does anyone know an alteriate solution to retreaving the value from the class?
You need to allocate storage for your static member, need
float ObjectInfo::Rotation;
outside your class definition.