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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:44:26+00:00 2026-05-14T14:44:26+00:00

i got a compile error which i do not understand. i have a h/cpp

  • 0

i got a compile error which i do not understand.
i have a h/cpp file combination that does not contain a class but just defines some utility functions. when i try to use a struct that is defined in another class i get the error:

error C2027: use of undefined type ‘B::C’

so, stripped down to the problem, the h-file looks like this

namespace A {
    void foo(B::C::SStruct const & Var);
}

the definition of SStruct is in a class which is in another h-file, that is of course included.

namespace B {
    class C {
        public:
        struct SStruct { };
    };
}

the strange thing is, i can use this struct in other classes fine, it just seems to be related to this one h-file which contains just utility functions.
what am i missing here?
thanks!

  • 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-14T14:44:26+00:00Added an answer on May 14, 2026 at 2:44 pm

    After correcting missing semicolons etc. this compiles:

    namespace B {
        class C {
            public:
            struct SStruct { };
        };
    }
    namespace A {
        void foo(B::C::SStruct const & Var);
    }
    

    Obviously, if the order of the two namespaces were switched, this would not work. Possibly you are #including your headers in the wrong order. If this is the error, that’s bad design – you should not allow header order to matter in your code.

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

Sidebar

Related Questions

I got this error when I tried to compile an application that includes the
I've got m2eclipse plugin installed and there's no problem syncing compile time dependencies that
Got a class that serializes into xml with XMLEncoder nicely with all the variables
I have a problem in a VB.Net class library which I have simplified greatly
Just got a question about generics, why doesn't this compile when using a generic
I've got a console application that compiles and executes fine with Visual C++ 6.0,
Got a bit of a mind freeze at the moment. I have the following
I have a vector of Student objects which I want to sort using #include
We've got an Enterprise system which has many processes (EXEs, services, DCOM servers, COM+
Got a bluescreen in windows while cloning a mercurial repository. After reboot, I now

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.