question

Hello, i try to make tihis code just for more understand how to send two datatype in dicleration statement, but it does not run it says "no overloaded fun take 2 parameters" how!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<string>
using namespace std;
template<typename T,typename S>
class oh{
T num1;
S num2;
public:
oh(T num11,Snum22){
num11=num1;
num22=num2;
}
T add(){
return nu1+num2;
}
};
int main(){
oh<int,double>obj(3,1.1);
cout<<obj.add();

system("ppause");
return 0;
}

thank you
You have several typos:
1
2
3
4
oh(T num11,S num22){ // Note: Space betwee S and num22
num1=num11; // Note: assignment to the member and not the parameter
num2=num22; // Note: assignment to the member and not the parameter
}
1
2
3
T add(){
return num1+num2; // Note: num1 not nu1
}
Topic archived. No new replies allowed.