Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. copying base class object to derived class object

copying base class object to derived class object

Scheduled Pinned Locked Moved C#
comhelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hasansheik
    wrote on last edited by
    #1

    Hi everybody, can any one of you guide me to solve the following problem. I have a property 'Properties' returns 'Editor' type object, which is a read only property of LookupEdit Control. now I am overloading the LookUpEdit control as MyLookUpEdit Control. in MyLookUpEdit Control i want to override the property 'Properties' to return an object of 'MyEditor' class. MyEditor class is derived from 'Editor' class. obvously it extends functionality of Editor class. whenever the user of 'MyLookUpEdit' access the propety 'Properties' it has to return the 'MyEditor' object the problem is i dont have a copyconstructor in Editor class. I hope I have explained the problem as it is. regards, Mohamed Hasan. Contact him at: hasansheik@hotmail.com hasansheik@yahoo.co.in hasansheik@lycos.com

    S 1 Reply Last reply
    0
    • H hasansheik

      Hi everybody, can any one of you guide me to solve the following problem. I have a property 'Properties' returns 'Editor' type object, which is a read only property of LookupEdit Control. now I am overloading the LookUpEdit control as MyLookUpEdit Control. in MyLookUpEdit Control i want to override the property 'Properties' to return an object of 'MyEditor' class. MyEditor class is derived from 'Editor' class. obvously it extends functionality of Editor class. whenever the user of 'MyLookUpEdit' access the propety 'Properties' it has to return the 'MyEditor' object the problem is i dont have a copyconstructor in Editor class. I hope I have explained the problem as it is. regards, Mohamed Hasan. Contact him at: hasansheik@hotmail.com hasansheik@yahoo.co.in hasansheik@lycos.com

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      You don't need to write a copy constructor (nor can you write one). Why do you want to write one? What exactly is the problem you're facing? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      H 1 Reply Last reply
      0
      • S S Senthil Kumar

        You don't need to write a copy constructor (nor can you write one). Why do you want to write one? What exactly is the problem you're facing? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        H Offline
        H Offline
        hasansheik
        wrote on last edited by
        #3

        this is exactly my problem. Class LookUpEdit { private Editor editor; public Editor Properties { get{ return editor; } } } I am deriving the above class class MyLookUpedit :LookUpedit { public MyEditor Editor { get { /// I need something like this. return (MyEditor)base.Properties; } } } here is the MyEditor's implementation class MyEditor : Editor { MyEditor() { } } do you have an idea. please try this. Contact him at: hasansheik@hotmail.com hasansheik@yahoo.co.in hasansheik@lycos.com

        S 1 Reply Last reply
        0
        • H hasansheik

          this is exactly my problem. Class LookUpEdit { private Editor editor; public Editor Properties { get{ return editor; } } } I am deriving the above class class MyLookUpedit :LookUpedit { public MyEditor Editor { get { /// I need something like this. return (MyEditor)base.Properties; } } } here is the MyEditor's implementation class MyEditor : Editor { MyEditor() { } } do you have an idea. please try this. Contact him at: hasansheik@hotmail.com hasansheik@yahoo.co.in hasansheik@lycos.com

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          How you construct MyEditor is up to you. My guess is MyEditor will have additional data members, so you might want to fill them, in addition to Editor members, before returning it. Something like

          class MyEditor : Editor
          {
          private additionMember;
          public MyEditor(Editor d)
          {
          //Assign base members here
          baseMember1 = d.baseMember1;
          }
          public int AdditionalMember
          {
          // get and set
          }
          }

          class MyLookUpedit :LookUpedit
          {
          public MyEditor Editor
          {
          get
          {
          MyEditor editor = new MyEditor(base.Properties);
          editor.AdditionalMember = 20;
          return editor;
          }
          }
          }

          Hope this helps. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups