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

  • SEARCH
  • Home
  • 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 6732305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:38:02+00:00 2026-05-26T10:38:02+00:00

I have a class SafeChargeDeposit inheriting from BaseExternalDeposit . the BaseExternalDeposit require in its

  • 0

I have a class SafeChargeDeposit inheriting from BaseExternalDeposit.
the BaseExternalDeposit require in its constructor a variable type BaseDepositStructure.

Since It requires BaseDepositStructure I cant use its child’s elements in SafeChargeDeposit.

this is the code:

 abstract class BaseExternalDeposit
    {
        public abstract BaseExternalDepositResult DoDeposit();

        protected BaseDepositStructure depositStructure;

        public BaseExternalDeposit(BaseDepositStructure depositStructure)
        {
            this.depositStructure = depositStructure;
        }
    }


 class SafeChargeDeposit : BaseExternalDeposit
 {
       public SafeChargeDeposit(CreditCardDepositStructure depositStructure):base(depositStructure){}

       public override BaseExternalDepositResult DoDeposit(){

        /////// I CAN USE THIS MEMBER:
        depositStructure.Amount = 50;

        /////// BUT I CANNOT USE THIS MEMBER:
        depositStructure.CreditCardNumber = "123456"; 
       }
 }


public class BaseDepositStructure
    {
        public double Amount = 0.0;
    }

    public class CreditCardDepositStructure : BaseDepositStructure
    {
        public string CreditCardNumber = string.Empty;
    }

I understand why I can use depositStructure.Amount and can’t use depositStructure.CreditCardNumber …
But what is wrong with my design here? how can I solve this issue and keep the flexibility of using Bases.

  • 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-26T10:38:03+00:00Added an answer on May 26, 2026 at 10:38 am
    interface IBaseExternalDepositResult
    {
    };  // eo interface BaseExternalDepositResult
    
    interface IDeposit
    {
        void Deposit();
    };
    
    // class BaseExternalDeposit<>
    abstract class BaseExternalDeposit<B> : IDeposit where B : BaseDepositStructure
    {
        private B depositStructure_;
        protected abstract IBaseExternalDepositResult DepositImpl();
        protected B Structure { get { return depositStructure_; } }
    
        public BaseExternalDeposit(B depositStructure)
        {
            depositStructure_ = depositStructure;
        }   // eo ctor
    
    
        // IDeposit
        void Deposit()
        {
            DepositImpl();
        }
    }   // eo class BaseExternalDeposit<B>
    
    
    // class SafeChargeDeposit
    class SafeChargeDeposit : BaseExternalDeposit<CreditCardDepositStructure>
    {
        protected override IBaseExternalDepositResult DepositImpl()
        {
            Structure.Amount = 50;
            Structure.CreditCardNumber = "123456";
        }   // eo DepositImpl
    
    
        public SafeChargeDeposit(CreditCardDepositStructure depositStructure)
            : base(depositStructure)
        {
        }
    }   // eo class SafeChargeDeposit
    
    
    public class BaseDepositStructure
    {
        public double Amount = 0.0;
    }
    
    public class CreditCardDepositStructure : BaseDepositStructure
    {
        public string CreditCardNumber = string.E
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class B derived from class A. I call copy constructor that I
I have class class DateOptTimeType implements org.hibernate.usertype.UserType that works with two columns @org.hibernate.annotations.Type(type =
I have class User that contains protected constructor and class Account that has access
I have class A and B which inherit from Base. Base has a private
I have class MyForm which inherited from QMainWindow . Here's my code: std::auto_ptr<MyForm> pForm(new
I have class that holds Tree Items for a Tree. Say the constructor looks
I have class StatusesInvestmentRow (from dataSource) where one of the field is ModifiedDate Investment
I have class ShowCase that inherite from my class ContentMC (that inherite from MovieClip).
I have class named CiF and I want to move in the constructor pointer
I have class two ViewModels //both IViewModel1 and IViewModel2 inherit from IViewModel public class

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.