C# inheritance broken?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andre Kaufmann

    #61
    Re: C# inheritance broken?

    groups@isaacsof t.com wrote:
    Reflection is no good, because of the amount of time it takes to make
    a copy for a large document.
    It wasn't my intention to use reflection directly, but to use it to
    create new source code, which has implemented all methods of the
    Document object, so that you don't have to do the wrapping by "hand".

    Andre


    Comment

    • gerry

      #62
      Re: C# inheritance broken?




      "Andre Kaufmann" <andre.kaufmann _re_move_@t-online.dewrote in message
      news:eqeM8lWRHH A.3440@TK2MSFTN GP03.phx.gbl...
      groups@isaacsof t.com wrote:
      >Reflection is no good, because of the amount of time it takes to make a
      >copy for a large document.
      >
      It wasn't my intention to use reflection directly, but to use it to create
      new source code, which has implemented all methods of the Document object,
      so that you don't have to do the wrapping by "hand".
      >
      Andre
      >
      >

      Comment

      • Bruce Wood

        #63
        Re: C# inheritance broken?

        On Jan 30, 12:48 pm, Andre Kaufmann <andre.kaufmann _re_mo...@t-
        online.dewrote:
        Mike Schilling wrote:
        <gro...@isaacso ft.comwrote in message
        news:1170084841 .336327.226140@ l53g2000cwa.goo glegroups.com.. .
        [...]
        But you haven't shown a C++ solution either, since the cast in your example
        doesn't work.
        >
        If a constructor is added like in the following example, it will work.
        Think that was the intention of Tony.
        >
        class Document
        {
        public:
        Document(){}
        static Document Load() { return Document(); }
        >
        };
        >
        class MyDocument : public Document
        {
        public:
        MyDocument() {}
        MyDocument(Docu ment& s) : Document(s) {}
        static MyDocument Load() { return Document::Load( ); }
        >
        };
        >
        int main(int argc, char* argv[])
        {
        MyDocument s = MyDocument::Loa d();
        return 0;
        >
        }
        Aren't you forgetting something? Where is the copy constructor for
        Document that accepts a pointer to a Document and creates a new
        document from it? (Invoked on the line:

        MyDocument(Docu ment& s) : Document(s) {}

        ) Or is this copy constructor somehow automatically generated by the C
        ++ compiler?

        Comment

        • Andre Kaufmann

          #64
          Re: C# inheritance broken?

          Bruce Wood wrote:
          [...]
          MyDocument(Docu ment& s) : Document(s) {}
          >
          ) Or is this copy constructor somehow automatically generated by the C
          ++ compiler?

          Exactly. C++ will automatically generate a copy constructor on a binary
          basis (memcopy) or will call a user defined one for each of the class
          variables. However, a developer can make the copy constructor private in
          a class and then you surely can't construct an object as I did in the
          example.

          Andre

          Comment

          • Ignacio Machin \( .NET/ C# MVP \)

            #65
            Re: C# inheritance broken?

            Hi,

            "Jake Stevenson" <jakestevenson@ gmail.comwrote in message
            news:1169914194 .828747.169760@ q2g2000cwa.goog legroups.com...
            >
            Something similar can be implemented in the base class and would be
            inherited by your class. There may be a performance issue with
            Reflection though.
            >
            In C++ I remember this idea has a name, a copycon constrctor?

            What strike me as weird is what is the problem in handling a Docment in the
            first place, IMO MyDocument extend Document but the application should be
            made to handle Document as default. And finally the readed file IS A
            document.



            Comment

            Working...