By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,330 Members | 1,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,330 IT Pros & Developers. It's quick & easy.

Non type template parameter Help

P: n/a
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.c pp(14): error C2143:
syntax error : missing ',' before ')'

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

what am I doing wrong?

Jun 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Adnan wrote:


I am getting following error

e:\RnD\C++\Templates\TmplFnNonType\TmplFnNonType.c pp(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.
Jun 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.