Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
QuestionBroken DLL Pin
musefan3-Jun-11 5:53
musefan3-Jun-11 5:53 
AnswerRe: Broken DLL Pin
Ennis Ray Lynch, Jr.3-Jun-11 6:07
Ennis Ray Lynch, Jr.3-Jun-11 6:07 
GeneralRe: Broken DLL Pin
musefan3-Jun-11 6:18
musefan3-Jun-11 6:18 
GeneralRe: Broken DLL Pin
SledgeHammer013-Jun-11 6:46
SledgeHammer013-Jun-11 6:46 
GeneralRe: Broken DLL Pin
musefan5-Jun-11 23:28
musefan5-Jun-11 23:28 
AnswerRe: Broken DLL [SOLVED] Pin
musefan5-Jun-11 23:31
musefan5-Jun-11 23:31 
QuestionClasses inheritance and something that confuses me Pin
nstk2-Jun-11 20:54
nstk2-Jun-11 20:54 
AnswerRe: Classes inheritance and something that confuses me PinPopular
Wayne Gaylard2-Jun-11 21:36
professionalWayne Gaylard2-Jun-11 21:36 
If you did it like this

C#
class Employee 
        {
            public void Talk()
            {
                MessageBox.Show("I am an Employee.");
            }
        }

        class ContractEmployee: Employee 
        {
            public void ContractTalk()
            {
                MessageBox.Show("I am a Contract Employee.");
            }
        }


and then tried to do this

C#
static void CreateEmployee()
        {
            Employee e = new ContractEmployee();
            e.Talk();
            e.ContractTalk();
        }


you would see that e only has access to e.Talk(). The compiler throws an error when you try and access e.ContractTalk() because e does not have access to ContractEmployee's methods. I think the example in the book is misleading because you aren't doing anything by decalring an Employee and instantiating a ContractEmployee. It would be different if Employee was an abstract class and it implemented an interface. Then derived classes would be forced to implement the methods defined in the interface, something like this,

C#
interface IEmployee
        {
            void Talk();
        }

        abstract class Employee : IEmployee
        {
            public abstract void Talk();
        }

        class PermanentEmployee:Employee
        {
            public override void Talk()
            {
                MessageBox.Show("I am a Permanent Employee.");
            }
        }

        class ContractEmployee: Employee 
        {
            public override void Talk()
            {
                MessageBox.Show("I am a Contract Employee.");
            }
        }


then it would make sense to do something like this

C#
static void CreateEmployee()
        {
            Employee e = new ContractEmployee();
            e.Talk();
            e = new PermanentEmployee();
            e.Talk();
        }


Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....

AnswerRe: Classes inheritance and something that confuses me Pin
Richard MacCutchan2-Jun-11 21:44
mveRichard MacCutchan2-Jun-11 21:44 
GeneralRe: Classes inheritance and something that confuses me Pin
nstk2-Jun-11 22:02
nstk2-Jun-11 22:02 
GeneralRe: Classes inheritance and something that confuses me Pin
Richard MacCutchan2-Jun-11 22:28
mveRichard MacCutchan2-Jun-11 22:28 
GeneralRe: Classes inheritance and something that confuses me Pin
MicroVirus3-Jun-11 1:40
MicroVirus3-Jun-11 1:40 
GeneralRe: Classes inheritance and something that confuses me Pin
Richard MacCutchan3-Jun-11 3:31
mveRichard MacCutchan3-Jun-11 3:31 
GeneralRe: Classes inheritance and something that confuses me Pin
nstk3-Jun-11 11:48
nstk3-Jun-11 11:48 
GeneralRe: Classes inheritance and something that confuses me Pin
BobJanova3-Jun-11 4:29
BobJanova3-Jun-11 4:29 
GeneralRe: Classes inheritance and something that confuses me Pin
nstk3-Jun-11 20:35
nstk3-Jun-11 20:35 
AnswerRe: Classes inheritance and something that confuses me Pin
Łukasz Nowakowski2-Jun-11 22:05
Łukasz Nowakowski2-Jun-11 22:05 
AnswerRe: Classes inheritance and something that confuses me Pin
_Erik_3-Jun-11 3:35
_Erik_3-Jun-11 3:35 
AnswerRe: Classes inheritance and something that confuses me Pin
Ravi Bhavnani3-Jun-11 5:48
professionalRavi Bhavnani3-Jun-11 5:48 
AnswerRe: Classes inheritance and something that confuses me Pin
Abhinav S3-Jun-11 21:23
Abhinav S3-Jun-11 21:23 
QuestionBasic Question On Constructor Stuff Pin
PozzaVecia2-Jun-11 10:10
PozzaVecia2-Jun-11 10:10 
AnswerRe: Basic Question On Constructor Stuff Pin
Ian Shlasko2-Jun-11 10:15
Ian Shlasko2-Jun-11 10:15 
GeneralRe: Basic Question On Constructor Stuff Pin
PozzaVecia2-Jun-11 10:21
PozzaVecia2-Jun-11 10:21 
AnswerRe: Basic Question On Constructor Stuff Pin
PIEBALDconsult2-Jun-11 16:23
mvePIEBALDconsult2-Jun-11 16:23 
GeneralRe: Basic Question On Constructor Stuff Pin
PozzaVecia3-Jun-11 11:10
PozzaVecia3-Jun-11 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.