From -7562417119828880451 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,64409d9769f709f0 X-Google-Attributes: gid109fba,public X-Google-Thread: f78e5,64409d9769f709f0 X-Google-Attributes: gidf78e5,public From: "Jon Andri Sigurdarson" Subject: Re: Is this legal C++? Date: 1998/08/06 Message-ID: <35ca46f5.0@news.isholf.is>#1/1 X-Deja-AN: 378580406 X-NNTP-Posting-Host: 194.105.225.103 Approved: stephen.clamage@sun.com (comp.std.c++) References: <01bdc100$f82d21b0$19011a12@bwing> X-UID: 0000000001 X-Status: $$$T X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 X-Trace: 6 Aug 1998 17:14:45 -0800, 194.105.225.103 Organization: Sun Microsystems Inc., Mountain View, CA Organziation: - Newsgroups: comp.lang.c++,comp.std.c++ Originator: clamage@taumet If U are using your Bar class in your Foo template class and want to access the constructor then the: a.T::Bar() sentence is not nessesary. It really doesn't do anything what hasn't already been done when U decleare your variable ( T a; ) So, I don't really get why on earth you wanna make something like: a.T::T(); work because the constructor is always called when you declare your variable. If you wanna call some other functions in the Foo constructor, like I'm calling Test(), you have to be sure Test() is always in the class you try to use with your template class, BUT this is not a good programming habbit !!!!!!!!! #include class Bar{ public: Bar(){cout<<"constructor"< class Foo{ public: (){ T a; //a.T::Bar(); // this doesn't do anything a.T::Test(); // } }; int main(int argc, char **argv){ Foo b; return 1; } I hope this tells you something ! Jon Andri mailto:digit@isholf.is Jason Hunter wrote in message <01bdc100$f82d21b0$19011a12@bwing>... >I have searched all over the C++ spec to see if this code is correct. I >think it ought to be, but I haven't been >able to find a compiler (tried, MSVC, Solais c++, Dec c++, Cxx, g++) who >will compile it. In fact, they all give >approximately the same error. Since this conservation of errors is pretty >rare among compilers I am beginning >to think it is in fact not valid. If it is not valid can someone tell me >how to do the same thing in a syntacally valid >way? > >here's the code. > > >class Bar >{ >public: > Bar() { } > > int x; >}; > >template >class Foo >{ >public: > Foo() > { > T a; > > a.T::Bar(); // this works! > a.T::T(); // C2039: 'T' is not a member of Bar. > } >}; > >int main(int argc, char **argv) >{ > Foo b; > > return 1; >} [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]