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 5978633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:32:38+00:00 2026-05-22T21:32:38+00:00

the implementer class ‘thefoo’ takes an integer from its constructor. but the base class

  • 0

the implementer class ‘thefoo’ takes an integer from its constructor. but the base class ‘foo’ can not see its constructor value ‘input’. because the base ctor works first. i’m need of some way to tell the base that implementer’s ctor value. without changing the base can i make passed the following failingtest?

public abstract class foo
    {
        int noImplementerKnowsThatValue = 0;
        protected abstract int intro();
        protected abstract int outtro();

        public foo()
        {
            noImplementerKnowsThatValue += intro ();
        }

        public int compose ()
        {
            return noImplementerKnowsThatValue + outtro ();
        }
    }
    public class theFoo : foo
    {
        int value;

        public theFoo (int input)
        {
            value = input;
        }

        protected override int intro ()
        {
            return value;
        }

        protected override int outtro ()
        {
            return 100;
        }
    }

    public class fooTest
    {
        public void failingTest ()
        {
            var foo = new theFoo (100);
            int x = foo.compose ();
            Debug.Assert (200 == x);
        }
    }
  • 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-22T21:32:39+00:00Added an answer on May 22, 2026 at 9:32 pm

    You can’t. Not unless you change the base class.

    Well, I suppose you could make

    protected override int intro ()
    {
        return 0;
    }
    protected override int outtro ()
    {
        return 100 + value;
    }
    

    But I think that’s not what you mean. And it doesn’t solve the general case of this problem (for instance, if instead of int there would be string).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented VirtualPathProvider class so I can keep all my views in the
Implemented the Sink Class - to receive event notifications from COM Server Event Interface
I have the simple class using auto-implemented properies: Public Class foo { public foo()
I am using a base class to my Popup windows on a WPF application.
When using jmock, you can mock a concrete class if you set the class
i have a class implemented from QGraphicsItem, called Node. i have a rectangle shaped
I am using AndroidFX Visualizer class in my demo app to read FFT but
I've a class implemented as below. In the constructor, I get a compilation error.
I recently implemented a class like: class TestClass : IDisposable { RegistryKey m_key; public
I've implemented a Class that extends Overlay and also override the onTap / onTouchEvent

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.