From 7316335421766109767
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,f470268b0e362fc1,start
X-Google-Attributes: gid109fba,public
X-Google-Thread: f97d0,f470268b0e362fc1,start
X-Google-Attributes: gidf97d0,public
X-Google-Thread: f78e5,f470268b0e362fc1,start
X-Google-Attributes: gidf78e5,public
X-Google-Thread: 10ba33,f470268b0e362fc1,start
X-Google-Attributes: gid10ba33,public
X-Google-ArrivalTime: 1993-12-02 09:53:26 PST
Xref: gmd.de comp.lang.c++:39597 comp.std.c++:4556 gnu.g++.help:3002
Path: gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!darwin.sura.net!wupost!wuecl.wustl.edu!saturn!abed
From: abed@saturn.wustl.edu (Abed M. Hammoud)
Newsgroups: comp.lang.c++,comp.std.c++,gnu.g++,gnu.g++.help
Subject: Is this valid C++ code ? Please help.
Date: 2 Dec 1993 17:14:53 GMT
Organization: Washington University, ESSRL
Lines: 46
Message-ID: <2dl7qd$fsb@wuecl.wustl.edu>
Reply-To: abed@saturn.wustl.edu
NNTP-Posting-Host: saturn.wustl.edu

Is this a valid C++ code. I would like to use some thing like that
so I can define a class that suppost multidimesnsional arrays.

Thanks, 

I am using g++ 2.5.3 on a sun-sparc station.
-----------------------------------------------------------------------------
#include <iostream.h>

template <class T, int dim>
class A {
public:
   T getSomthing(); 
   A(int); 
   ~A(); 
private:
   int xxx; 
}; 

template <class T, int dim>
A<T, 1>::A(int x) : xxx(x) {cout << "Hello this is 1" << endl; }

template <class T, int dim>
A<T, 2>::A(int x) : xxx(x) {cout << "Hello this is 2" << endl; }

template <class T, int dim>
A<T, 1>::~A() {cout << "Bye this is 1" << endl; }

template <class T, int dim>
A<T, 2>::~A() {cout << "Bye this is 2" << endl; }

template<class T, int dim>
T A<T, 1>::getSomething() { return xxx; }

template<class T, int dim>
T A<T, 2>::getSomething() { return xxx * xxx; }

main() {

   A<float, 1> BB(1); 
   cout << BB.getSomething() << endl; 

   A<double, 1> CC(1); 
   cout << CC.getSomething() << endl; 

}


