Slimelite BBS

theoretical template question

Back to EMULATE

From Darin McBride · 1996-04-04 02:35 · #73662 in EMULATE

 DM> i.e.,

 DM> template <class T> coordinate
 MB> * * *
 DM> struct _X {};
 DM> typedef coordinate<_X> X;

 DM> struct _Y {};
 DM> typedef coordinate<_Y> Y;

 MB> You can use built-in types to instantiate a 
 MB> parameterized template.  That is, the syntax 
 MB> "coordinate<int> X;" and "coordinate<int> Y;" is 
 MB> perfectly legal.

Remember: I wanted type 'X' to be not equivalent to type 'Y'.  I wanted to be able to say:

class point{
  public:
    point(X xpos, Y ypos);
    point(Y ypos, X xpos);
...
};

(which means that the program must make explicit whether the integer is an X position or a Y position) and the compiler won't complain that the two are the same.

Would your example do this?  I'm not sure...


--- Maximus/2 3.01
 * Origin: Tanktalus' Tower BBS (PVT) (1:342/708)