473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

abstract class inheritance

I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}

Nov 16 '05 #1
8 4388
Dan
Claire,

You have a typo somewhere in your code, or the problem is somewhere else. I
simply cut and pasted your example code below into a new class file, and
created

A eg = new C();

and it compiled fine. (c# with .Net 1.1)

Daniel.

"Claire" <bl****@blahhhhh.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}

Nov 16 '05 #2
Dan
Claire,

You have a typo somewhere in your code, or the problem is somewhere else. I
simply cut and pasted your example code below into a new class file, and
created

A eg = new C();

and it compiled fine. (c# with .Net 1.1)

Daniel.

"Claire" <bl****@blahhhhh.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}

Nov 16 '05 #3
Claire wrote:
I have a base abstract class A which contains several abstract
functions
I then have an abstract class B (derived from A) which overrides a
small subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented
the inherited abstract members defined by A. But I overrode these
functions in B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}


It should compile. And it actually does for me (.NET 1.1, VS .NET 2003).

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 16 '05 #4
Claire wrote:
I have a base abstract class A which contains several abstract
functions
I then have an abstract class B (derived from A) which overrides a
small subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented
the inherited abstract members defined by A. But I overrode these
functions in B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}


It should compile. And it actually does for me (.NET 1.1, VS .NET 2003).

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 16 '05 #5
Claire wrote:
I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}


Verify that you have everything correct. The code you have above
compiles fine (after commeting out doodar as that doesn't exist) as it
should. But this appears to be just sample code, not the real stuff.
Is the error about not implementing Function1 in C the only error you
are getting?
--
Tom Porterfield
Nov 16 '05 #6
Claire wrote:
I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}


Verify that you have everything correct. The code you have above
compiles fine (after commeting out doodar as that doesn't exist) as it
should. But this appears to be just sample code, not the real stuff.
Is the error about not implementing Function1 in C the only error you
are getting?
--
Tom Porterfield
Nov 16 '05 #7
did you miss out the override keyword on one of the method implementations
in B in the real code.

In that case the C# compiler would assume that the new method is unrelated
to the abstract one (as it didn't deliberately use the override keyword)

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

"Claire" <bl****@blahhhhh.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
I have a base abstract class A which contains several abstract functions

I then have an abstract class B (derived from A) which overrides a small
subset of A's abstract functions

Finally I have a fully functional class C (deriving from B). Class C
overrides the (A's) abstract functions not tackled by its ancestor B.

I am complained at by the compiler, that in C, I have not implemented the
inherited abstract members defined by A. But I overrode these functions in
B!

Is this correct and why?

Claire

public abstract class A
{
public abstract void Function1();
public abstract void Function2();
public abstract void Function3();
}

public abstract class B : A
{
public override void Function1()
{
doodar;
}
}

public class C : B
{
public override void Function2()
{
}
public override void Function3()
{
}
// Compiler complains that C has not implemented Function1
}

Nov 16 '05 #8
thanks all, I agree with you, it must have been a typo somewhere.
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dan Sikorsky | last post by:
If we were to define all abstract methods in an abstract class, thereby making that class non-abstract, and then override the heretofore 'abstract' methods in a derived class, wouldn't that remove...
10
by: Brett | last post by:
I'm still trying to figure out concrete reasons to use one over the other. I understand the abstract class can have implementation in its methods and derived classes can only inherit one abstract...
10
by: Joe | last post by:
My question is more an OOD question. I know *how* to implement both abstract classes and interfaces. Here's my question - under what circumstacnes does one use an abstract class and under what...
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
6
by: Steve | last post by:
I am designing a new class hierarchy and I've already run into a bit of a bump in the road. I have this structure so far; class CodeGen class CodeGenHeader : CodeGen class CodeGenProtocolHeader...
4
by: J.M. | last post by:
I have a question concerning inheritance: can an abstract (parent) class have an abstract object? I would like to make a concrete child inherit from this class by inheriting from this object. Let...
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
6
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it...
21
by: Mr.SpOOn | last post by:
Hi, I'm going to work on a project to represent some musical theory in Python, in an object oriented way. I have to manage many elements of music such as notes, intervals, scales, chords and so...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.