Skip to main content
gamedev.net
🔒 Locked

[.net] Inheritance question.

Started by andyb716 1 reply 300+ views
Original Post
andyb716
andyb716
Hi I have a base Object class where in the constructor I pass in a device. My Line drawing class inherits from the object class. But I don't know how to code the constructor for it. It says the Object class constructor doesnt take 0 arguments.
mike25025
mike25025
if your using c++ it would look something like this

class A{	D* m_d;public:	A(D* d);};A::A(D* d){	m_d = d;}class B : public A{public:	B(D* d);	// or	B();};B::B(D* d) : A(d){	// do something here}// orB::B() : A(g_d) // g_d is a global pointer to a D{	// do something here}
andyb716
andyb716
Thanks, I am using c# though I figured it out, I just used b : base(d) and it works fine, thanks for the help

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.