Question: okay - maybe this is a silly question and cast operators do this already inherently..

What I have:

* some external class definition of a 4x4 Matrix
* some own 4x4 Matrix class

both classes interally simply store a float[16];

i'd like to define in my Matrix class a cast operator so that I can do things like:

```
MyMatrix4x4 m;
OtherMatrix4x4(m).someFunctionDefinedInOtherMatrix4x4();
SomeFunctionThatTakesOtherMatrix4x4(OtherMatrix4x4(m));

```

And I don't want this operator to copy any data - the functions should simply operate on the same float[16] data

How to do that?

Answer: 
```
OtherMatrix4x4(m)

```

This isn't a cast operator, it's a **conversion constructor**.

Suppose the following definition of `MyMatrix4x4`:

```
struct MyMatrix4x4
{
    float x[16];
};

```

The the following should do it:

```
struct OtherMatrix4x4
{
    float* x;
    OtherMatrix4x4(MyMatrix4x4& other)
    {
       x = other.x;
    }
    void foo()
    {
       x[0] = 0;
    }
};

```

To test:

```
MyMatrix4x4 a = {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}};
OtherMatrix4x4(a).foo();
cout << b.x[0]; //will output 0, not 1

```

**EDIT** Here's the version where you cant edit the other matrix:

```
struct OtherMatrix4x4
{
    float x[16];
    void foo()
    {
        x[0] = 0;
    }
};

struct MyMatrix4x4
{
    float* x;
    operator OtherMatrix4x4()
    {
        OtherMatrix4x4 other;
        x = other.x;
        return other;
    }
};

MyMatrix4x4 m;
OtherMatrix4x4(m).foo();

```
Just to present a different solution presenting inheritance. These would allow the use of code you posted above. However this is not a cast operator.

```
class MyMatrix4x4 {
public:
    float f;
};

class OtherMatrix4x4 : MyMatrix4x4  {
public:
    OtherMatrix4x4(MyMatrix4x4 &matrix)
    {
        f = matrix.f;
    }

    void someFunctionDefinedInOtherMatrix4x4();
};

```