constructor template- template class

Hello!
Says that template syntax for constructor is not ok.

Can't google the solution, can someone help?
many thanks!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  template <class xxx> class calc{
xxx a;
xxx b;

public: 

  calc(xxx,xxx);
  xxx add(){return (a+b);}
  xxx mult(){return (a*b);}
  };

template <class xxx> xxx calc<xxx>::calc(xxx c, xxx d) : a(c), b(d) {}


int main(){

calc obj1(1,2);
calc obj2(3,4);

cout<<obj1.add()<<endl;
cout<<obj2.add()<<endl<<endl;

cout<<obj1.mult()<<endl;
cout<<obj2.mult()<<endl;

return 0;
}
 
 


Does your compiler's error message point any particular column of the offending line? I don't recall seeing a compiler that would only say: "not ok".
Line 12: template <class xxx> xxx calc<xxx>::calc(xxx c, xxx d) : a(c), b(d) {}

Line 17/18: calc<int> obj... // Note: You need to provide the template type
Hello!
Please, I tried with normal form of function (not-inline), then I got the result.

I thought, inline function IN THE CLASS, if declared as PUBLIC, IS in the scope.

Do I loose it from the scope if I declare it inline within the class, even if it is public?

Many thanks, compeltely confused at the moment!
Topic archived. No new replies allowed.