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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:30:10+00:00 2026-06-04T17:30:10+00:00

I have a set of classes to implement and I plan to do it

  • 0

I have a set of classes to implement and I plan to do it in the following way:

(1) A master header file (entity.h) that has all the forward declarations of these classes enclosed in a namespace i.e.:

namespace SomeNameSpace {
    class A;
    ...
    class E;
}

(2) Each of the classes then have separate header files (i.e. A.h, B.h) that defines the classes and declares all the constituent variables and methods.

(3) And finally, the .cpp’s that define all the members and statics (i.e. A.cpp, B.cpp).

Now, I tried to put this scheme to work by doing #include "entity.h", but I am slapped with an “ambiguity” error whenever I try to use one of these classes. If I skip step (1) and simply include all the individuals header files of each class, then I don’t have that problem (and that’s how I’ve been writing code).

So anyway, is my scheme viable? Is there some way to make it work? What I really wanted is to have some sort of way to put every custom object in one namespace. I suppose I can make that work by simply putting all the class declarations into one file, but that’d make entity.h bloated.

I’ve searched around with keywords “forward declaration”, “C++”, “namespace”, “one namespace”, “master header”, “header” and couldn’t find anything that’s quite relevant. Maybe what I want to do is wrong?

  • 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-06-04T17:30:12+00:00Added an answer on June 4, 2026 at 5:30 pm

    You cannot use “class A;” in your entity.h because that means that you are actually declaring a class but you already have done so in A.h
    You can either add the whole declaration in your entity.h but not using any A.h, B.h etc.
    Or, you can just use the same namespace in each *.h file :
    A.h ->
    namespace SomeNamespace {
    class A …
    }

    B.h ->
    namespace SomeNamespace{
    class B …
    }

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

Sidebar

Related Questions

If have a set of classes that all implement an interface. interface IMyinterface<T> {
Present Scenario : I have a set of classes that all take a common
I have a set of classes where my base has a constructor that takes
I have a set of classes that all need to be acted on in
I have a set of classes that implement a particular interface and I have
I have a set of classes ( MyClass1, MyClass2, MyClass3 ) that implement an
If I have some classes that implement the same interface, so they all contain
I have written a set of classes and interfaces that are implemented in Moose
I'm using ASP.NET MVC RC2. I have a set of classes that were auto-generated
I have a set of data classes that I'd like to extend with my

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.