C++ : Creating Object by parameter with call of function

Kristian Kratzenstein kristian.kratzenstein@kielnet.net
Tue Apr 26 18:10:00 GMT 2005


Hi,

Didn't found a easy topic, hopefully anyone could understand.
My problem is following :
My class (lets call it dclass) alloc his own memory. This is done in the
constructors.
The class is a parameter of a function (like func(dclass aObj){}).
The class has several contructors with different datatypes (char*, FSSpec,
... and dclass&).
Now I want to call the function als with something like
func("abcd");
func(spec);

Now at normal the object aObj should be contructed with the givin
parameter. This is running well on VisualStudio.
But on CodeWarrior 8.3 &  XCode (gcc). get a errormessage during compiling
:
dclass(dclass) does not match
dclass(char *)
dclass(FSSpec)
dclass(dclass&)

Seem like the call of the function creates a temp object of class dclass
(with the correct contructor) and then this temp object is given as
parameter to the function. But can't handle to give the reference of the
temp object to the aObj constructor.

Is there a way around this ? I need this, cause the class alloc his own
memory.

Thanks in advanced,

Kristian Kratzenstein




More information about the Gcc-help mailing list