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
Administrator
Tech Writer
2.2k
1.5m
Inheritance
Mar 17 2003 4:12 PM
I have 3 classes, myClass1, myClass2, and myBaseClass. The simplified code looks like this public class myClass1: myBaseClass { public int myClassInt = 0; public myClass1() { IncreaseTheInteger(); } } public class myClass2: myBaseClass { public int myClassInt = 0; public myClass2() { IncreaseTheInteger(); } } public class myBaseClass { public myBaseClass() { } public void IncreaseTheInteger() { // increase the calling class's integer by 5 myClassInt += 5; // ERROR: myBaseClass doesn't know what myClassInt is. } } As you can see, the 2 derived classes (myClass1 and myClass2) both have a public integer named myClassInt. Both of these classes inherit from myBaseClass which contains a function called IncreaseTheInteger(). As I showed above, what I want to do is this: // in the myBaseClass::IncreaseTheInteger function myClassInt += 5; The problem here is that myBaseClass doesn't know what myClassInt is. To say it simply, what I want to be able to do is allow 2 classes to be able to use a function in a third class. Is this possible?
Reply
Answers (
2
)
XML Question
needed: C# equivelent of GetElementByID