Is it possible to overload abstract method?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm new to c# and anything related to .net, so not even sure if I'm on the right track. I receive an error that says my LoginEvent does not implement inherited abstract memeber AddEvent(). If I remove AddEvent() and just leave the AddEvent(str w, str x, str y, str z), it works fine. Here's some code:

//PARENT CLASS
abstract public class AuditEvent
{
public AuditEvent()
{
}

//overloaded method to be implemented by derived classes
public abstract void AddEvent();
public abstract void AddEvent(string w, string x, string y, string z);
}

//DERIVED CLASS
public class LoginEvent : AuditEvent
{
public LoginEvent()
{
}

public override void AddEvent(string a, string b, String c, string d)
{ //do stuff
}
}
 
I'm new to c# and anything related to .net, so not even sure if I'm on the right track.
I receive an error that says my LoginEvent does not implement inherited abstract memeber AddEvent().
If I remove AddEvent() and just leave the AddEvent(str w, str x, str y, str z), it works fine. Here's some code:

Right, the error message is right on then. You either have to
implement AddEvent() in LoginEvent, or make the LoginEvent class
abstract as well.

To answer the question in your subject line; Yes.



Mattias
 
jacobryce said:
I'm new to c# and anything related to .net, so not even sure if I'm
on the right track. I receive an error that says my LoginEvent does
not implement inherited abstract memeber AddEvent(). If I remove
AddEvent() and just leave the AddEvent(str w, str x, str y, str z),
it works fine. Here's some code:

<snip>

You can certainly overload an abstract method - but you still need to
provide an implementation for all abstract methods in the abstract
class in order to let your derived class be concrete (non-abstract).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top