spark@gmuvax2.gmu.edu (Sooyong Park) (03/01/91)
HAVE YOU TRIED THE FOLLOWING?
As far as I know, C++ does not provide parameterized types.
Is there any way we can simulate parameterized types ?
For example, to build a class for LIST which has a generic
type, I may program as follows. Please tell me your way
of doing so.
class INT_LIST : public LIST {
...
...
put(int val) { ..}
...
}
class CHAR_LIST : public LIST {
...
put(char val){ .. }
where,
class LIST {
...
LIST(int n) { new gentype[n] }
put(gentype val) { ... }
...
}
Many thanks in advance.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
EMail: spark@gmuvax2.gmu.edu
USMail: Sooyong Park
Computer Science
George Mason Univ
Fairfax, VA 22030jimad@microsoft.UUCP (Jim ADCOCK) (03/05/91)
In article <3666@gmuvax2.gmu.edu> spark@gmuvax2.gmu.edu (Sooyong Park) writes: |HAVE YOU TRIED THE FOLLOWING? | |As far as I know, C++ does not provide parameterized types. |Is there any way we can simulate parameterized types ? |For example, to build a class for LIST which has a generic |type, I may program as follows. Please tell me your way |of doing so. The ANSI-C++ committee added parameterized types [aka "templates"] to the working definition of the language in November. Expect more and more compilers to add support for such. See ARM chapter 14 for how templates work.