Re: Help with my program (code inside)

From: Karl Heinz Buchegger (kbuchegg_at_gascad.at)
Date: 11/14/03


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


Relevant Pages

  • Re: a method to make js have the ability to inherit
    ... but without the implied type-conversion of the string ... that uses the name of a specific constructor. ... programmer has no idea at all what types of object they are ... no reason for ever doing so. ...
    (comp.lang.javascript)
  • Re: Newbie question: Writing your own class
    ... is made by a class's Create constructor method which allocates memory ... FDefinition: string; ... every other descendant of TObject ... Result:= FDefinition; ...
    (comp.lang.pascal.delphi.misc)
  • Re: About speed
    ... property Name: String read fName; ... constructor TProperty.Create; ... fValue: PropertyOfT_DataType; ... constructor Create(other: TPropertyOfT); overload; ...
    (borland.public.delphi.non-technical)
  • Re: a method to make js have the ability to inherit
    ... discriminating but without the implied type-conversion of the string ... makes no use of an object's - constructor - property anyway.) ... programs should serve some known purpose known to the programmer. ... var o = Father.prototype; ...
    (comp.lang.javascript)
  • Re: Re: Slightly OT ? regarding posting to this group...
    ... I am not an old time usenet user, ... Bottom posting take much scrolling. ...
    (microsoft.public.dotnet.languages.vb)