Re: How to access base class member from derived class ?

2018-09-26 Thread Stefan_Salewski
You may also compare your code with this example of OOP inheritance: [https://forum.nim-lang.org/t/4226](https://forum.nim-lang.org/t/4226) The corrected code of lscrd should compile and work. I think your own code on the top is a bit "strange and dangerous" as you manually initialize member

Re: How to access base class member from derived class ?

2018-09-25 Thread kcvinu
I have few questions. Please answer this if you don't mind. 1. I have used ref objects in my code. Is that a good practice or bad practice ? 2. You suggested to including base type in child type as member is a good idea. Ok, but is there any overhead problems in it ? For example, i only

Re: How to access base class member from derived class ?

2018-09-23 Thread kcvinu
@Hlaaftana, Thank you for the reply. That's a good suggestion but you didn't tell me that does my approach contains any problem ? By the way, i didn't faced any problem in initializing the child window.

Re: How to access base class member from derived class ?

2018-09-23 Thread Hlaaftana
You never modify the result or return anything in `NewChildWindow`. And since ChildWindow is an object and not a ref object, it will initialize all its fields to their default values which is why cw has no children. I think what you want to do is in line with the super constructor calls in

Re: How to access base class member from derived class ?

2018-09-23 Thread kcvinu
I have got a work around. See this ; I just add a variable which contain the whole base class. type BaseWindow = ref object of RootObj title : string width : int height : int windowCount : int windowList : seq[int]

How to access base class member from derived class ?

2018-09-23 Thread kcvinu
Hi all, Please see this code. I somehow managed to access base class member from child class, by giving the base as parameter in child's ctor. See this code. But i cant access the base class member from instantiated child variable. type BaseWindow = ref object of RootObj