'VBA Class Inheritance
I am working on a script to help me create geometry in 3D software based on user input and I wanted to approach the problem with classes. I have 3 levels of structures, points, curves and surfaces so I want to create a class for each, where the next level structure inherits the lower one. So for example class cPoint have 4 properties: x,y,z,id. Further, the class cCurve has only 2 properties: id and points, and the same for surfaces. Now my question is: I implemented class cPoint as follows:
Private x_ As Double
Private y_ As Double
Private z_ As Double
Private id_ As Long
Public Property Let X(ByVal value As Double)
x_ = value
End Property
Public Property Let Y(ByVal value As Double)
y_ = value
End Property
Public Property Let Z(ByVal value As Double)
z_ = value
End Property
Public Property Let ID(ByVal value As Long)
id_ = value
End Property
Public Property Get X() As Double
X = x_
End Property
Public Property Get Y() As Double
Y = y_
End Property
Public Property Get Z() As Double
Z = z_
End Property
Public Property Get ID() As Long
ID = id_
End Property
and everything is fine here. And here I have class cCurve implemented:
Implements cPoint
Private id_ As Long
Private point_ As Collection
Public Property Let ID(ByVal value As Long)
id_ = value
End Property
Public Property Set point(ByVal value As Collection)
Set point_ = value
End Property
Public Property Get ID() As Long
ID = id_
End Property
Public Property Get point() As Collection
Set point = point_
End Property
But here, when I try to run the code I get prompted with the following error:
Object module needs to implement 'X' for interface 'cPoint'
I think I know what it means, but I have no clue how to implement it. Is my approach even correct?
I'd highly appreciate any guidance in this manner.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
