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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:40:19+00:00 2026-05-19T11:40:19+00:00

Hell, the title probably wasn’t the best, but I’m a fairly new programmer and

  • 0

Hell, the title probably wasn’t the best, but I’m a fairly new programmer and haven’t had much experience with inherited classes. I’m trying to initialize a class (my own Stream derived from the normal FileStream class) and have the option of initializing the base from the derived’s arguments. For example…

public class Example : FileStream
{
public Example(FileStream FS) : base = FS
}

Obviously I can’t just do that, but it best shows what I’d like to do. The main reason why I’m doing this is because of contradicting streams — and what I mean by that is that within this class, another class automatically opens the file (and does some reading and whatnot) and I get thrown an exception that the file is inaccessible. Maybe I’m doing this wrong, but thanks for everyone’s time!

  • 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-19T11:40:19+00:00Added an answer on May 19, 2026 at 11:40 am

    You can’t do that, no. But for Stream specifically, you can derive from Stream, store the FileStream in a private field and pass all the method calls to it:

    public class Example : Stream
    {
        private Stream _underlying;
    
        public Example(Stream underlying) { _underlying = underlying; }
    
        // Do the following for all the methods in Stream
        public override int Read(...) { return _underlying.Read(...); }
    }
    

    If you move the text cursor to the word Stream after the Example :, press Alt+Shift+F10 and choose “Implement abstract class Stream”, it will generate all the method declarations for you, but you will still have to change all the throw new NotImplementedException() into the proper calls to _underlying.

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

Sidebar

Related Questions

I'm a fairly new programmer, but I consider my google-fu quite competent and I've
We are using PowerDesigner at work for database modelling. But there is a hell
I know that the title is very subtle but I have absolutely no idea
I know.. I know, it's only a few hours old. But how the hell
Hell-o all, Im new to qt and I am having trouble drawing one single
I am in DataGrid hell right now but that's another post. Anyway, I wrote
So... I'm still in unicode hell... New problem... On my computer, everything shows perfectly.
very simple code, but leaks as hell... check it out. - (void)loadView { NSString
Microsoft seems hell-bent on deprecating the swiss-army-knife of database tools. What else comes close
What is classpath hell and is/was it really a problem for Java?

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.