<<< | Index | >>> |
//point.h class Point { public: int m_coord[ 2 ]; int* m_ptr; Point() { m_coord[ 0 ] = -1; m_coord[ 1 ] = -1; m_ptr = m_coord; } void reset() { m_ptr[ 0 ] = 0; m_ptr[ 1 ] = 0; m_ptr = 0; } };//class Point |
//main.cpp #include <cassert> void main() { Point pt1; Point pt2; draw_segment( pt1, pt2 ); assert( pt1.m_coord[ 0 ] == -1 ); assert( pt1.m_ptr != 0 ); } |
//point.cpp void draw_segment( Point from, Point to ) { // Draw a line: // ... // Then reset objects: from.reset(); // Hmm?.. to.reset(); } |
<<< | Index | >>> |