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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:13:06+00:00 2026-05-26T08:13:06+00:00

So for class we have to make a D&D 3.5 game, and for the

  • 0

So for class we have to make a D&D 3.5 game, and for the first assignment I have to generate a Fighter character. The way I have the hierarchy set up in my head is character.cpp and it’s child is classname.cpp where it has some attributes specific to the class since all classes share the same basic things.

Is that a good structure for it? If it’s related we haven’t done STL yet.

Another issue that arose is since my teammate will be making a GUI for the game he may also make a class called character. I thought to resolve this I would make a namespace. But if I make each of the files I make have their class inside namespace d20 in each of their respective headers would all of those namespaces be one and the same? I can’t think of a very good way to word this question.

  • 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-26T08:13:07+00:00Added an answer on May 26, 2026 at 8:13 am

    Here’s my best stab at answering you…

    A good inheritance structure is very context specific, but the basic principle is a base class contains data and functions relevant to all the derived classes. Derived classes will contain specific data and functions to itself. In your case there will be a lot of data in the base class ‘character’ like all the character stats and functions that compute outcome based on stats (I’m assuming the rules of the game are generally class independent).

    I’m also assuming when you say ‘classname.cpp’ you mean ‘fighter.cpp’, ‘cleric.cpp’, etc. In that case, yes, I would agree with making it structured that way.

    STL doesn’t really have a direct impact on coming up with class hierarchies, so I would say no, it’s not related.

    As for namespaces, anytime you specify a namespace it will be the same as anywhere else you specify the exact same name (which is what I think you’re asking). You don’t need to do anything special to make it the same namespace other than naming it the same exact thing. A simple example is as follows:

    character.h

    namespace d20
    {
        class Character
        {
            Character();
            ~Character();
            //etc...
        }
    }
    

    character.cpp

    #include "character.h"
    namespace d20
    {
        Character::Character()
        {
            // Stuff...
        }
    
        Character::~Character()
        {
        }
    }
    

    fighter.h

    #include "character.h"
    namespace d20
    {
        class Fighter : public Character
        {
            Fighter ();
            ~Fighter ();
            //etc...
        }
    }
    

    OR (without the namespace keyword)

    #include "character.h"
    class Fighter : public d20::Character
    {
        Fighter ();
        ~Fighter ();
        //etc...
    }
    

    Edit: Please note that in the second case the Fighter class is NOT is the namespace d20, it just derives from a class in that namespace.

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

Sidebar

Related Questions

I have to make a game in Java for my computer science class. Since
I have to make a rudimentary FSM in a class, and am writing it
I have to make dynamic hashes, so the class example won't work since the
I have a following model: class Car(models.Model): make = models.CharField(max_length=40) mileage_limit = models.IntegerField() mileage
I have method in a class that I need to make sure is only
I have style sheet with a class name changebackgroundcolor i want make change in
To make a long story short I have to use processing in a class
I have a Products:List<Product> class. I'd like to make it so that every time
For a class project, we have to create a hangman game in Java (we're
I have a 4x3 matrix where the class is set to blank (white background).

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.