0

In WinDev, I have a base class, let say BaseClass. This base class has a constructor:

PROCEDURE CONSTRUCTOR(param1, param2, param3)

I have a first child class that extends the base class, let say childClass1. This first child has a constructor with the only 2 firsts arguments:

ChildClass1 is a class inherits from BaseClass
...

PROCEDURE CONSTRUCTOR(param1, param2)
Constructor BaseClass(param1, param2, 1)

And I would like to have a class that inherits from ChildClass1 but uses the constructor from BaseClass. It seems impossible without redefinning the 3 parameters constructor of BaseClass inside the ChildClass1.

Here is what I tried to do:

ChildClass2 is a class inherits from ChildClass1
...

PROCEDURE CONSTRUCTOR(param1, param2)
Constructor BaseClass(param1, param2, 2)

But is says that BaseClass is neither a base class or a member of ChildClass1.

Does the only solution is to redefine the constructor of BaseClass inside ChildClass1 so that ChildClass2 can use it?

This seems as a lack of OOP handling.

Cheers,

MHogge
  • 5,408
  • 15
  • 61
  • 104

1 Answers1

1

The explicit constructors of the base class or member must be called in first statement of the constructor of the derived class.
Example:

//----Declare the BaseClass1 class
BaseClass1 is Class
BaseClass1Member is int
END
//---- Constructor of BaseClass1
PROCEDURE Constructor(Param1)
Info("Constructor of BaseClass1 => " + Param1)
//----Declare the class named BaseClass2
BaseClass2 is Class
BaseClass2Member is int
END
//---- Constructor of BaseClass2
PROCEDURE Constructor(Param1)
Info("Constructor of BaseClass2 => " + Param1)
//---- Declaration of DerivedClass
DerivedClass is Class
// Inheritance of BaseClass1 whose 
// Constructor expects a parameter
inherits from ClassBase1
// BaseClass2 member whose 
// Constructor expects a parameter
DerivedClassMember is BaseClass2
END
//----Constructor of DerivedClass
PROCEDURE Constructor()
// Explicit call to Constructor
Constructor BaseClass1(10) 
Constructor DerivedClassMember(20)
Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29