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

C / C++ / MFC

 
GeneralRe: visual c++ Pin
Hamid_RT1-Mar-09 4:28
Hamid_RT1-Mar-09 4:28 
AnswerRe: visual c++ Pin
Jonathan Davies28-Feb-09 12:54
Jonathan Davies28-Feb-09 12:54 
QuestionFlashing Toolbar Buttons Pin
softwaremonkey28-Feb-09 7:41
softwaremonkey28-Feb-09 7:41 
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 
I've done some more testing and uncovered something interesting. The template method being called will work if the template parameter is not explicitly specified.

See the addtional method added to Class_with_template_method, "templatePassedIn". And the modified STS_OP_temp_test constructor.


#ifndef STS_OP_temp_test_HPP
#define STS_OP_temp_test_HPP

#include <typeinfo>
#include <iostream>
#include <string>


//------------------------------------------------------------------------------
template <typename T = int>
class Class_with_template_method
{
public:

//--------------------------------------------------------------------------
Class_with_template_method()
{}


//--------------------------------------------------------------------------
template <typename P>
void templateMethod()
{
std::cout << "Method template is of type: " << typeid(P).name() << std::endl;
}


//--------------------------------------------------------------------------
template <typename D>
void templatePassedIn(D p_passed)
{
std::cout << "Method template is of type: " << typeid(D).name() << std::endl
<< "And has value: " << p_passed << std::endl;
}

};


//------------------------------------------------------------------------------
template <template<typename> class U = Class_with_template_method >
class STS_OP_temp_test
{
public:


//--------------------------------------------------------------------------
STS_OP_temp_test()
{
cwtm.templatePassedIn(6); // works
cwtm.templatePassedIn<int>(6); // ERROR !!!

cwtm.templateMethod<int>(); // ERROR !!!
//------------------------------------------------------------------------------
real_cwtm.templateMethod<int>(); // works

real_cwtm.templatePassedIn(6); // works
real_cwtm.templatePassedIn<int>(6); // works
}

U<int> cwtm; // Care about template type

Class_with_template_method<> real_cwtm;

};

int main()
{

STS_OP_temp_test<> B();

return (1);
}
#endif

<div class="ForumMod">modified on Saturday, February 28, 2009 1:58 PM</div>
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 
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 

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.