TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ashes999
NA
2
0
Inheritence Problem -- Constructors
Jun 8 2004 4:35 PM
I apologize if this thread has been posted before--the Search link is currently not working. From my understanding, when you have a derived class, the constructors, by default, call the DEFAULT BASE CONSTRUCTOR. When I try and make constructors that don't have the same number of arguements as one of the base constructors, I get an error. Something like "no constructor in Base with
arguements". This is a problem because, for example, I'm doing DirectX 9 coding. I have a class "SurfaceObject" which creates a blank blittable surface, and a (derived) class BitmapObject that contains many of the same methods, but none of the same constructors. Eg. The BitmapObject constructors take in a filename of some sort, but the SurfaceObjects don't--they're blank. How do I work around this? Will virtal methods or interfaces work? Example (non-working): Public class Base { public Base(int x) { System.Console.WriteLine("X: " + x); } } Public class Derived : Base { public Derived(int x, int y) { // Error: No constructor of class Base takes 2 arguements System.Console.WriteLine("Y: " + y); } }
Reply
Answers (
1
)
Outlook events in vb.net
Create a MS word document using C#