:) sorry - the [] operator is indeed the indexing operator for the m_v array -
float & Mat4::operator [] ( int index ) { return( m_v[ index ] ); }
const float & Mat4::operator [] ( const int index ) const { return( m_v[ index ] ); }
and the m_v array is float m_v[16] for Mat4.
On Aug 17, 2011, at 12:42 AM, lbland wrote: hi- But now you need to define what the [int i] operator is, which can be anything (in C++). Is it v.m_v[i] ? or something else? … the class name Mat4 implies it is something else (to me)... thanks!- -lance On Aug 16, 2011, at 6:13 PM, J wrote: hi Lance,
Of course you're right, I should've given the code for the << operator on Mat4, here it is:
std::ostream & operator << ( std::ostream & s, const Mat4 & v ) {
static char txt[256];
sprintf( txt, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", \
v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ], \
v[ 4 ], v[ 5 ], v[ 6 ], v[ 7 ], \
v[ 8 ], v[ 9 ], v[ 10 ], v[ 11 ], \
v[ 12 ], v[ 13 ], v[ 14 ], v[ 15 ] );
s << txt;
return s;
}
On Aug 16, 2011, at 11:48 PM, lbland wrote:
hi-
On Aug 16, 2011, at 5:27 PM, J wrote:
Is there anyone who can explain the discrepancy between the left and right
panes in the image linked to below ? the right pane - the printed output is the expected output.
However, the variables view shows a completely different layout of the values in the
matrix, which has a float m_v[16] member which is printed.
The << infix operator doesn't need to print in order of the memory layout? What is the implementation for << in the class?
thanks!-
-lance
|