im writing a programe to calculate the steering angle of a wheel given design specs. not to bore you all with trivial race car suspension geometry design, but knowing the non linear rack motion to wheel angle is important for determining maximum grip.
my actually problem is this: i have a class "data" which has a struct "steerAngleData" in it. i initialized the struct steerAngleData inner, in the IMP file, and can use to data::PrintList fine. however when i try to input values into the struct in another class, it will not recognize the structure. i have tried using derived classes, friends, and virtual
i've spent a good amount of time on google to no avale, so if this is a very obvious problem(which im sure it is) im sorry.
im completely out of ideas at this point, so any help would be great.
Thanks
that makes sense, but why can i access variables in derived classes that were initialized in the parent class? if that works, why cant i get the structure to work, even if getSpecs is a derived class of data?
if i initialize the structure outside any class it would be a global struct, and accessible to all files, including main driver correct?
this is where i am trying to modify a struct value.
1 2 3
inner[i].wheelAngleRaw=steerAngleFinal; //error here- "use of undeclared identifier "inner"
inner[i].wheelAngle=steerAngleFinal;
This is a scope problem. Your 'inner' and 'outer' arrays do not exist. You declare them in your data() constructor, which means they go out of scope and die as soon as the constructor exits.
They are not part of your data class. If you want them to be part of your class, they have to actually be declared in the class body:
1 2 3 4 5 6 7
class data
{
//...
steerAngleData inner[21];
steerAngleData outer[21];
//...
};
Do this, and remove the declaration from the constructor, and you should be good to go.