Click here to Skip to main content
15,905,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Flashing Toolbar Buttons Pin
Code-o-mat28-Feb-09 7:51
Code-o-mat28-Feb-09 7:51 
GeneralRe: Flashing Toolbar Buttons Pin
softwaremonkey1-Mar-09 6:16
softwaremonkey1-Mar-09 6:16 
GeneralRe: Flashing Toolbar Buttons Pin
Code-o-mat1-Mar-09 6:57
Code-o-mat1-Mar-09 6:57 
QuestionMethod template in a class template [compiling error, help] [modified] Pin
jim258kelly28-Feb-09 6:08
jim258kelly28-Feb-09 6:08 
NewsRe: Method template in a class template [compiling error, help] [modified] Pin
jim258kelly28-Feb-09 7:30
jim258kelly28-Feb-09 7:30 
AnswerRe: Method template in a class template [compiling error, help] Pin
Stuart Dootson28-Feb-09 9:37
professionalStuart Dootson28-Feb-09 9:37 
GeneralRe: Method template in a class template [compiling error, help] Pin
jim258kelly28-Feb-09 10:34
jim258kelly28-Feb-09 10:34 
GeneralRe: Method template in a class template [compiling error, help] Pin
Stuart Dootson28-Feb-09 11:31
professionalStuart Dootson28-Feb-09 11:31 
jim258kelly wrote:
So, if I owned a copy of the C++ Standard, would I have found the answer there?


Possibly - the standard can take some decoding at times (yes, I have a copy). I don't know, I didn't look at the standard.

jim258kelly wrote:
How did you know this?


Deduction really - you have to think 'what can the compiler infer, given what it knows'. You've told it that U is a template class, taking a single parameter. So when you assert that it has a member 'templateMethod', that's fine - it's willing to accept that. But when you add the '<', what does it mean? There are two options - it could be a less than operator or it could be a template parameter clause introduction - there's ambiguity. So, to disambiguate, either the compiler gets cleverer (looks like VC++2008 has done that) or you have to explicitly tell the compiler that 'templateMethod' is a template.

With templates, the two things that most often come up are 'can the compiler tell that this symbol is a template' (the case you had) or 'can the compiler tell this is a type', at which point you need to add a 'typename' qualifier, similar to the 'template' one. Consider the (contrived) code below. Without the 'typename', it won't compile (not with g++, anyway) because the compiler can't know that A::size_type is actually a type.

#include <vector>
#include <iostream>

template <class A>
struct GetSize
{
   typename A::size_type operator()(A const& a) { return a.size(); }
};

int main()
{
   std::vector<int> a(10);
   std::cout << GetSize<std::vector<int> >()(a) << std::endl;
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionString table Updation Pin
Alex@9C28-Feb-09 5:39
Alex@9C28-Feb-09 5:39 
AnswerRe: String table Updation Pin
Code-o-mat28-Feb-09 7:37
Code-o-mat28-Feb-09 7:37 
QuestionPicture Control Pin
daavena28-Feb-09 5:36
daavena28-Feb-09 5:36 
AnswerRe: Picture Control Pin
Code-o-mat28-Feb-09 7:42
Code-o-mat28-Feb-09 7:42 
GeneralRe: Picture Control Pin
daavena28-Feb-09 7:49
daavena28-Feb-09 7:49 
GeneralRe: Picture Control Pin
Code-o-mat28-Feb-09 7:52
Code-o-mat28-Feb-09 7:52 
GeneralRe: Picture Control Pin
daavena28-Feb-09 8:19
daavena28-Feb-09 8:19 
GeneralRe: Picture Control [modified] Pin
Code-o-mat28-Feb-09 8:31
Code-o-mat28-Feb-09 8:31 
GeneralRe: Picture Control Pin
daavena28-Feb-09 9:09
daavena28-Feb-09 9:09 
GeneralRe: Picture Control [modified] Pin
Code-o-mat28-Feb-09 9:22
Code-o-mat28-Feb-09 9:22 
GeneralRe: Picture Control Pin
daavena28-Feb-09 9:46
daavena28-Feb-09 9:46 
QuestionLarge number generator in c++ Pin
Mark Elrod28-Feb-09 5:12
Mark Elrod28-Feb-09 5:12 
AnswerRe: Large number generator in c++ Pin
Stuart Dootson28-Feb-09 9:45
professionalStuart Dootson28-Feb-09 9:45 
QuestionDebugging Problem Pin
rkshdixit28-Feb-09 0:41
rkshdixit28-Feb-09 0:41 
AnswerRe: Debugging Problem Pin
Iain Clarke, Warrior Programmer28-Feb-09 1:34
Iain Clarke, Warrior Programmer28-Feb-09 1:34 
GeneralRe: Debugging Problem Pin
rkshdixit28-Feb-09 2:59
rkshdixit28-Feb-09 2:59 
GeneralRe: Debugging Problem Pin
ky_rerun28-Feb-09 16:11
ky_rerun28-Feb-09 16:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.