This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
C++ : Creating Object by parameter with call of function
- From: "Kristian Kratzenstein" <kristian dot kratzenstein at kielnet dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 26 Apr 2005 17:28:40 +0200
- Subject: C++ : Creating Object by parameter with call of function
- References: <1114528827.29413.ezmlm@gcc.gnu.org>
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