Non type template parameter Help

A

Adnan

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?
 
I

Ian Collins

Adnan said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top