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
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
@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.
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
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]
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