This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]