Followers 0

# How to get rid of this?

## 5 posts in this topic

Hiya, i was wondering if someone could help me with a design flaw in my library's vector and matrice code. See, like i posted here, i always need to access the x,y,z part of the vector by the letter v, and m for matrices.

Another example would be

ApplyMatrixToVector(&p->ThrustVector.v, &p->JetMatrix.m);



It's kinda annoying to have those v and m letters appended everywhere, but im affraid to modify the code since it work perfectly well.

Also, I know the ApplyMatrixToVector() should be done by overriding the '*' operator but it's already overloaded for something else i think.

Here the source:

vector.h

vector.cpp

Matrix.h

Matrix.cpp

Thx

EDIT: Humm, i know the the header file look a bit strange, it was done that way to compile the library either normally or in dll for multiples languages, just don't mind the #defines (another thing to fix, i need to remove this, but that i dont need help with :) )

Edited by Vortez
0

##### Share on other sites

Thx for the answer bac, this clear things up a bit. Great explanation btw, i'll look into it.

0

##### Share on other sites

Ok, so i was speaking with Kathar the other night in the chat about those classes and he did a wonderfull job helping me out. The thing is, im not very used to reference in c++, i always use pointers, but i understand what they are and, i almost understand when to use them but it's tripping me off sometime. Here's the code:

Vector.h

Vector.cpp

Matrix.h

Matrix.cpp

What i don't get is, should't this, for example

CMatrix _EXP_FUNC operator+(CMatrix m1, const CMatrix &m2);

be

CMatrix _EXP_FUNC operator+(const CMatrix &m1, const CMatrix &m2);

???

It mostly confuse me in operator overloading functions... maybe he just missed that, or am i wrong?

1

##### Share on other sites

The non-reference variant uses m1 as that temporary variable.

I see, i think i understand better now.

0

## Create an account

Register a new account