C# Inherit Base Class Needs Variable - How?
-
Hello, I'm normally a C++ .NET programmer but I'm building a DirectX game in C# .NET. I'm having a problem understanding how to pass a variable (directX device) to my Base class when declaring a Derived class. Example:
class Base { public Base( Device device ) {} ..process device physics.. } class Derived:Base { public Derived() {} ..variables for whatever object this is.. }
How would I declare an object of Derived class and pass my device object to the base class? Thanks for the help. Cyric74@hotmail.com -
Hello, I'm normally a C++ .NET programmer but I'm building a DirectX game in C# .NET. I'm having a problem understanding how to pass a variable (directX device) to my Base class when declaring a Derived class. Example:
class Base { public Base( Device device ) {} ..process device physics.. } class Derived:Base { public Derived() {} ..variables for whatever object this is.. }
How would I declare an object of Derived class and pass my device object to the base class? Thanks for the help. Cyric74@hotmail.comTry this class Base { public Base( ) { } public Base( Device device ) { int i =11; } } class Derived:Base { public Derived( Device device ):base(device) { int i =10; } } class Device { } Device device = new Device(); Derived der = new Derived(device); Or Change the BASE constructor to a Method. Sanjay Sansanwal www.sansanwal.com
-
Try this class Base { public Base( ) { } public Base( Device device ) { int i =11; } } class Derived:Base { public Derived( Device device ):base(device) { int i =10; } } class Device { } Device device = new Device(); Derived der = new Derived(device); Or Change the BASE constructor to a Method. Sanjay Sansanwal www.sansanwal.com