0

Hi,

I am writing a simple graphics engine using homegeneous coordinates (fourVector) and the corresponding 4matrices (fourMatrix).

fourVector.cpp:

```
fourVector::fourVector(float x, float y, float z, float w): x(x),y(y),z(z),w(w){
};
```

fourMatrix.h

```
class fourMatrix{
public:
fourVector i,j,k,l;
...
}
```

fourMatrix.cpp:

```
fourMatrix::fourMatrix():i(fourVector(1,0,0,0)),j(fourVector(0,1,0,0)),k(fourVector(0,0,1,0)),l(fourVector(0,0,0,1)){}
fourMatrix::fourMatrix(fourVector &i, fourVector &j, fourVector &k, fourVector &l): i(i),j(j),k(k),l(l){
}
...
inline fourMatrix& fourMatrix::rotationX(float a){
fourMatrix n;
n.i=fourVector(1,0,0,0);
n.j=fourVector(0,cos(a),sin(a),0);
n.k=fourVector(0,-sin(a),cos(a),0);
n.l=fourVector(0,0,0,1);
return n;
```

The above code compiles but seems rather bloated(especially for an inline function): I want to avoid the definition of the local fourMatrix n, so that I write something like:

```
inline fourMatrix& fourMatrix::rotationX(float a){
return fourMatrix(fourVector(1,0,0,0),fourVector(0,cos(a),sin(a),0),
fourVector(0,-sin(a),cos(a),0),fourVector(0,0,0,1);
```

However when I try this I get the following error

```
../Geometry/fourMatrix.cpp: In member function ‘fourMatrix& fourMatrix::rotationX(float)’:
../Geometry/fourMatrix.cpp:351: error: no matching function for call to ‘fourMatrix::fourMatrix(fourVector, fourVector, fourVector, fourVector)’
../Geometry/fourMatrix.cpp:156: note: candidates are: fourMatrix::fourMatrix(float, float, float, float)
../Geometry/fourMatrix.cpp:123: note: fourMatrix::fourMatrix(float, float)
../Geometry/fourMatrix.cpp:112: note: fourMatrix::fourMatrix(float)
../Geometry/fourMatrix.cpp:23: note: fourMatrix::fourMatrix(const Vector&, const Vector&, const Vector&)
../Geometry/fourMatrix.cpp:104: note: fourMatrix::fourMatrix(fourVector&)
../Geometry/fourMatrix.cpp:100: note: fourMatrix::fourMatrix(Vector&)
../Geometry/fourMatrix.cpp:207: note: fourMatrix::fourMatrix(fourMatrix&)
../Geometry/fourMatrix.cpp:14: note: fourMatrix::fourMatrix(fourVector&, fourVector&, fourVector&, fourVector&)
../Geometry/fourMatrix.cpp:12: note: fourMatrix::fourMatrix()
```

and if I rewrite the fourMatrix constructor

```
fourMatrix::fourMatrix(fourVector i, fourVector j, fourVector k, fourVector l): i(i),j(j),k(k),l(l){
}
```

I get the following error.

```
../Geometry/fourMatrix.cpp: In member function ‘fourMatrix& fourMatrix::rotationX(float)’:
../Geometry/fourMatrix.cpp:354: error: invalid initialization of non-const reference of type ‘fourMatrix&’ from a temporary of type ‘fourMatrix’
```

Clearly I am doing something fundamentally wrong. The problem lies with the fourMatrix constructor, to which I prefer to pass the fourVector objects as a reference.

Thanks in advance for constructive responses