home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16821 < prev    next >
Encoding:
Text File  |  1992-11-24  |  1.4 KB  |  47 lines

  1. Xref: sparky comp.lang.c++:16821 comp.std.c++:1613
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!xjzhu
  4. From: xjzhu@math.uwaterloo.ca (Xiaojun Zhu)
  5. Subject: Can we refer to A<T, S> when we are constructing A<S, T>? A challenge!
  6. Message-ID: <By78zI.D8L@math.uwaterloo.ca>
  7. Keywords: template, argument switching
  8. Organization: University of Waterloo
  9. Date: Tue, 24 Nov 1992 02:45:17 GMT
  10. Lines: 35
  11.  
  12. I have an interesting question for you C++ experts out there.
  13.  
  14. Q: Can we refer to A<T, S> when we are constructing A<S, T>?
  15.  
  16. I had experimented it with AT&T C++ V3.0 and the fun part is probably not
  17. to give you the answer.
  18.  
  19. Please answer the following questions before resorting to your compiler.
  20. (out of your knowledge)
  21.  
  22. Q1: Should we be allowed to use or not to use? 
  23.  
  24. Q2: Why or why not?
  25.  
  26. template<class S, class T>
  27. class A
  28. {
  29.   S _s;
  30.   T _t;
  31. public:
  32.  //...
  33.  // the following function is trying to switch a._s and a._t
  34.  // to give me an A<T, S> object.
  35.  friend A<T,S>& SWITCH(A<S,T>& a);  // interesting place
  36.                   
  37. };
  38.  
  39.  
  40. --------------------------------------------------------------
  41.    A template version of my signature class is under repair.
  42. Symptom: It dies without a warning if I use certain class 
  43.          as an argument.
  44.          
  45.                                        xjzhu@math.uwaterloo.ca
  46. --------------------------------------------------------------
  47.