0

Dear All,

I’m implementing a vector class that allows me to do vector arithmetic.

What I’ve implemented is the following:

```
class mVec
{
private:
float vec[3];
public:
mVec();
mVec(const float * const parray);
mVec(const float a, const float b, const float c);
~mVec();
mVec operator+(const mVec& param);
mVec operator-(const mVec& param);
//other operators...
float* useAsArray() { return vec; }
};
```

As I have already created many functions that work with arrays of three floats, I would like to make my class mVec also compatible with them, without having to overload all these functions.

What apparently works is the member function “useAsArray()”, as it allows me to pass arguments to functions as pointer-to-float, and in this way I can read or write data member vec inside of mVec.

Something like this:

`void normalizeVector(float* vec);`

Could be used like this:

`normalizeVector( a.useAsArray() );`

Although it seems to work properly I’m not sure if this is the correct way of doing things. I will appreciate any advice on how to do it better.

Thanks in advance!

Regards,

M.