Powershell: 5.1.1904.1
OS: Windows 10 Pro x64, version 2004
I'm probably missing something incredibly obvious here, but...
I have a base class and a subclass.
class Vehicle {
[string]$Name
Vehicle($Name) {
$this.Name = $Name
}
}
class Car : Vehicle {
[int]$NumWheels
Car($Name, $NumWheels) {
$this.NumWheels = $NumWheels
}
}
$testVar = [Car]::new("Ford Fiesta", 4)
When calling the subclass constructor I'm getting the message
Cannot find an overload for "new" and the argument count: "0".
When I remove the class inheritance I can call the constructor. Powershell seems to find it.
When I remove the inheritance and get info on the constructor
[Car]::new
I see
OverloadDefinitions
-------------------
Car new(System.Object Name, System.Object NumWheels)
When inheritance is specified (Car : Vehicle) I still get
OverloadDefinitions
-------------------
Car new(System.Object Name, System.Object NumWheels)
Totally unclear why this it seems to see the constructor, but I'm unable to call it when I inherit.
I know I have to be doing something wrong here. :P
Thank you in advance