VC++ Template problem
-
VC++ 6.0 has a problem with templates I'm told. what is it? Obseve everything, remember more...
It does not support partial template specialisation, which in particular, means you cannot do the sort of template metaprogramming which has become trendy since the 'Modern C++ Design' book came out. While it is a pain, ( and still not fixed in VC7, yet ), it really doesn't stop 95% of the dev work likely to happen using templates. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
It does not support partial template specialisation, which in particular, means you cannot do the sort of template metaprogramming which has become trendy since the 'Modern C++ Design' book came out. While it is a pain, ( and still not fixed in VC7, yet ), it really doesn't stop 95% of the dev work likely to happen using templates. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
Thanks. I ask because with the free compiler DEV-C++ I had a very very basic swap function, and the code would not compile under VC++ when copied in to it. Obseve everything, remember more...
Shouldn't be a proble. The best approach would be to post the code, so we can comment. Remember to tick the box under this main edit box that says 'display this message as-is (no HTML)', or anything between <> will be lost. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
Shouldn't be a proble. The best approach would be to post the code, so we can comment. Remember to tick the box under this main edit box that says 'display this message as-is (no HTML)', or anything between <> will be lost. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
lol sorry I meant I had the code - ages ago. oh! it's still on my wall... template int Temp1(X &A, X &B) { X Var; Var = A + B; return Var; } Obseve everything, remember more...
Oh, I thought you were trying to do a swap. This is an add, and I'm not sure it has any value over simply adding without the function call. It will not compile if the type in question does not have an operator +. Because your return type is 'int' it also will not compile unless the template argument is a number, and it will give warnings because it will strip floating point numbers down to an int. Swap would look like this ( except you'd add the template arguments being stripped by the site because neither of us checked 'show message as-is' ) template void Temp1(X &A, X &B) { X Var; Var = A; B = A; A = Var; } Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002