copying base class object to derived class object
-
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
-
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
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
-
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
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
-
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
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 likeclass 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