Reputation: 5803
When I try the below program its gives me the :error C2064: I tried in google but not able to find the exact reason. Please help.
class myClass
{
public:
void function(myClass dTemp)
{
cout<<"Inside myClass: taking myClass parameter"<<endl;
}
};
.
int main()
{
myClass myClassTemp;
myClass myClassTemp1;
myClassTemp(myClassTemp1);// error C2064: term does not evaluate to a function taking 1 argument.
return 0;
};
Upvotes: 0
Views: 5368
Reputation: 14603
You should include your function name when calling.
myClassTemp.function(myClassTemp1)
Or if your intention is functor object do it following way:
class myClass
{
public:
void operator() (myClass dTemp)
{
cout<<"Inside myClass: taking myClass parameter"<<endl;
}
};
.
int main()
{
myClass myClassTemp;
myClass myClassTemp1;
myClassTemp(myClassTemp1);
return 0;
};
Upvotes: 5
Reputation: 131829
Did you mean to be able to call an object of type myClass
like a function? You need to overload operator()
for that:
void operator()(myClass dTemp){
// ...
}
If you instead wanted to call the function, well, you should actually do so:
myClassTemp.function(myClassTemp1);
Upvotes: 6
Reputation: 38173
This should be
// vvvvvvvv
myClassTemp.function(myClassTemp1);
Upvotes: 3