Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5950815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:26:52+00:00 2026-05-22T17:26:52+00:00

I am creating an abstract base class which have functions implemented by other classes.

  • 0

I am creating an abstract base class which have functions implemented by other classes. My doubts are as follows

1) Do i need give ‘virtual’ in front of every function which need to be overridden by the child classes? I see some examples without the virtual keyword and still they are open to be overridden.

2) I need to have a function which will be implemented in the base class and i dont want it to be overridden by the child classes. I added the ‘fixed’ keyword infront of that function. Compiler start complaining ‘member’ cannot be sealed because it is not an override. Am i doing any wrong here?

abstract public class ShapeBase
    {
        private ShapeDetails _shapedDetails;

        public CampusCardBase(ShapeDetails shDetails)
        {
            _shapedDetails= shDetails;
        }

        public virtual void Draw();
        public virtual float getWidth();
        public virtual void Swap();
        public virtual void Erase();

        public sealed ShapeDetails getShapeDetails()
        {
            return _shapedDetails;
        }


    };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:26:52+00:00Added an answer on May 22, 2026 at 5:26 pm
    1. For methods without implementations in an abstract class, use abstract as well:

      abstract public void Draw();
      abstract public float getWidth();
      abstract public void Swap();
      abstract public void Erase();
      
    2. Methods aren’t overridable by default; they only allow derived classes to override if declared abstract, virtual or override (but not override sealed).

      Therefore you don’t need to give getShapeDetails() any other modifiers than public:

      public ShapeDetails getShapeDetails()
      {
          return _shapedDetails;
      }
      

    On a side note, you should stick with .NET naming conventions and capitalize method names using Pascal case, so getWidth() becomes GetWidth() and getShapeDetails() becomes GetShapeDetails().

    In fact you should be using a property getter for your _shapedDetails field instead of a getShapeDetails() method:

    private ShapeDetails _shapedDetails;
    
    public ShapeDetails ShapedDetails
    {
        get { return _shapedDetails; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently find myself creating classes which use this form (A): abstract class Animal
I have a bunch of classes extending an abstract Base class. Each subclass takes
If I'm creating an abstract base class, and the classes derived from it are
I have an abstract class defining a pure virtual method in c++: class Base
using C# I have a class which contains among other meta information the root
I have a class that inherits a base class to which another class has
I have a collection of classes that inherit from an abstract class I created.
I have a set of classes, each of which need to decide at some
I have the following classes: abstract class Transport{ protected String name; protected Transport(String name){
Following classes are created, no interface/abstract class for now: Test - for creating test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.