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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:04:53+00:00 2026-05-25T11:04:53+00:00

I was reading about creating classes and nested classes to determine what is the

  • 0

I was reading about creating classes and nested classes to determine what is the best approach for my needs, but I couldn’t find something similar to what I need ( or couldn’t understand it 😉 ).

I will give you guys a (almost) real-life example:

Let’s say I own a factory which manufactures different kinds of vehicles. So, my namespace would be Factory I figure.

Now, lets say the factory manufactures cars, boats and airplanes. So I will add three classes to my Factory namespace with those names.

Here is where my problem is with understanding the other methods:

I have some common things between the three types of vehicles. For example, they all have an engine (might be different HP or shapes which I understand are properties of the engine, but still they all have an engine). Also, cars and airplanes have doors (sometimes boats do too). On the other hand, they also have some unique things (airplanes have propellers for example that might come in different sizes or shapes).

Can someone please describe what I said in code so I could understand the differences between them?

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

    You could stick all these in your Factory namespace.

    A vehicle class would contain shared components, and classes for your specific vehicle types would inherit from the vehicle class… is that what you’re asking?

    public class Engine
    {
       public int HorsePower {get;set;}
    }
    
    public class Vehicle
    {
        public Vehicle() { }
    
        public Engine Engine;
        public int Doors;
    }
    
    public class Airplane : Vehicle
    {
        public Airplane () { }
    
        public string PropellerModel;
    }
    
    public class Boat : Vehicle
    {
        public Boat () { }
    
        public string RudderModel;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading about the problem of creating a read only primitive vector in C# (basically,
I am reading 《Internetworking with TCP/IP》 by Douglas Comer,and when talking about creating a
I've been reading lots of documents on the internet about creating a cross compiler
When reading about JQuery best practices, I read this recently: Never include Javascript events
I'm reading a tutorial about creating a shoutbox with jquery, php and ajax. In
Reading about the G.729 codec , I found this interesting tidbit about Comfort Noise
When reading about SQL Injection and XSS i was wondering if you guys have
I am reading about COFF file formats, which is commonly used to create an
I was reading about output buffering in JavaScript here , and was trying to
I keep reading about C99 and C++11 and all these totally sweet things that

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.