C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Non type template parameter Help

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Adnan
Guest





PostPosted: Fri Jun 16, 2006 9:10 am    Post subject: Non type template parameter Help Reply with quote



Hi!

I am newbie in template stuff and I am getting error for the following
program



#include "stdafx.h"
using namespace std;

template <class T,char ch>
class paramClass
{
public:
void addNumbers(T num1,T num2);
};

template<class T,char ch)

void paramClass<T,ch>::addNumbers(T num1,T num2)
{
cout<< "The character is " <<ch<<endl;
cout<<"The Addition is "<< num1+num2;
}

void main(void)
{
paramClass<int,'G'>objMultiple;
cout<< " The resultant is " <<objMultiple.addNumbers(4,5);
}


I am getting following error

e:\RnD\C++\Templates\TmplFnNonType\TmplFnNonType.cpp(14): error C2143:
syntax error : missing ',' before ')'

on line "template<class T,char ch)"

what am I doing wrong?
Back to top
Ian Collins
Guest





PostPosted: Fri Jun 16, 2006 9:10 am    Post subject: Re: Non type template parameter Help Reply with quote



Adnan wrote:
Quote:


I am getting following error

e:\RnD\C++\Templates\TmplFnNonType\TmplFnNonType.cpp(14): error C2143:
syntax error : missing ',' before ')'

on line "template<class T,char ch)"

what am I doing wrong?

Typing!


try template<class T,char ch>

--
Ian Collins.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.