Const Struct (Typedef?)

Pseudocode:

1
2
3
4
5
6
class Accel
{
public:
     Accel(const struct &F);
     etc...
};


I know this is wrong, it won't compile. I'm looking for WHY it is wrong, and how to fix it. I've been told that I need a type for my struct, but not how to do that. F is a struct made up of doubles (Fx, Fy, Fz). I obviously do not know a lot about structs, and maybe I shouldn't be programming with them, as I am more comfortable with vectors, but I wanted something that I could name the components more easily.

Thanks.
It's wrong because you haven't named the struct.
I have a whole list of struct variables created. For example, I have:

struct F {double Fx, Fy, Fz;};
So you should have
1
2
public:
    Accel(const F& Data)

And use "Data" in your constructor.

Reason:
After
struct F {double Fx, Fy, Fz;};
F is a new type, just like int, double, char or whatever.
So where you would use
void Function(const int& Data)
you should use
void Function(const F& Data)
Last edited on
What would "Data" be?
closed account (zb0S216C)
pbhuter wrote:
"What would "Data" be?"


Data is the name of the object; Data is a reference to a F constant.

Wazzak
Last edited on
It would be a correct code if you would write

1
2
3
4
5
6
class Accel
{
public:
     Accel(const struct F & );
     etc...
};


You could define structiure F itself below this definition of Accel in the same scope.
Topic archived. No new replies allowed.