Reputation: 16193
When using either boost::scoped_ptr
or boost::shared_ptr
I get the error
1>*\algomanager.cpp(28) : error C2064: term does not evaluate to a function taking 1 arguments
I have code like this . . .
class X{
boost::shared_ptr<cPreFilterProcess> preProcess;
public:
X(){
preProcess(new cPreFilterProcess(pars));
}
};
What am I missing? Thanks.
Upvotes: 0
Views: 729
Reputation: 131839
My mythical glass orb of magic debugging tells me you're doing something like this:
class X{
boost::shared_ptr<cPreFilterProcess> preProcess;
public:
X(){
preProcess(new cPreFilterProcess(pars));
}
};
You need to use either the member initializer like:
X() : preProcess(...){}
Or use .reset
since your can't just assign a pointer like that:
X() { preProcess.reset(...); }
I would strongly recommend the first option though.
Upvotes: 6
Reputation: 171393
If you just write this as a statement:
preProcess ( new cPreFilterProcess(pars) );
it's not valid, because preProcess
is already constructed, so that syntax tries to "call" it like a function.
This is not valid either:
preProcess = new cPreFilterProcess(pars);
because you can't assign a cPreFilterProcess*
to a shared_ptr<cPreFilterProcess>
Maybe you mean:
preProcess.reset( new cPreFilterProcess(pars) );
or
preProcess = boost::shared_ptr<cPreFilterProcess>( new cPreFilterProcess(pars) );
Upvotes: 3