Re: Help with my program (code inside)
From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 11/14/03
- Next message: Michael Lyszczek: "ATL/COM MFC API problem"
- Previous message: Krzysztof Kolago: "Reading data from file"
- In reply to: Silver: "Help with my program (code inside)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 14 Nov 2003 16:19:11 +0100
Silver wrote:
>
> Hi everyone,
>
> I'm writing a program that has to do them following
>
> main() :
> -------
> 3 objects are declared (two of type A and one of type B)
> The function frd_fun is called for two objects (B and one of A).
>
> C frd_fun(A a, B b)
> --------------------
> it returns an object of type C which contains a pointer that points to a
> string. This string contains the common elements of the strings in A and B.
>
> The description I give is short cause I don't you to write the code for me,
> just point me my mistakes.
>
> I also would like to have a destructor function for all my classes, where I
> will deallocate the memory (using delete)
At the moment you use the words:
dynamic allocation
destructor
class
in one sentence, the next logical question is:
What about the copy constructor and the assignment operator?
Scrolling through your source code I see: not implemented.
So looking further: is it a problem.
Again scrolling a little bit: Yes, it is.
frd_fun( A a, B b )
takes its parameters by value, thus copies of the callers arguments
are made. Since you didn't provide a copy constructor of your own, the
compiler provided one which does ... the wrong thing.
[snip a long posting of unreadable code which lacks indenting and has lots
of white lines in it]
If that doesn't answer your question, then I suggest you reread your original
posting and just using what you have written try to answer: What was the question
expressed in that posting?
-- Karl Heinz Buchegger kbuchegg@gascad.at
- Next message: Michael Lyszczek: "ATL/COM MFC API problem"
- Previous message: Krzysztof Kolago: "Reading data from file"
- In reply to: Silver: "Help with my program (code inside)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|