www.digitalmars.com         C & C++   DMDScript  

c++ - macro (bis)

i have the class:

template <class T, int DIM>
class npoint {
public:
.
.
	T& operator[](const int i) {
		return coord[i];
	}

.
.
public:
    T coord[DIM];
};

#define .x .coord[0]
#define .y .coord[1]
#define .z .coord[2]

does not compile: "identifier expected" because of .x, .y, .z #defines

my questions:
    - is it suposed to compile ?, if not, in few word why ? (just for my
general culture)
    - do i missed something, is there a way to make it compile ?

thanks

roland

PS: i know those #define are a little limit dangerous. made for
compatibility with existing code. 
and it is better than #define x coord[0] isn't it ?
Apr 06 2002