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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:20:17+00:00 2026-06-04T16:20:17+00:00

In C++, I can define a class within another class the declares member functions.

  • 0

In C++, I can define a class within another class the declares member functions. Later, when I am defining the definition for those declarations, is there a way to not keep repeating the containing class. For example, my header might look like this:

class Outer {
  class Inner {
    void one();
    void two();
    void three();
  };
};

And then later, my definitions might look like this:

void Outer::Inner::one() { ... }
void Outer::Inner::two() { ... }
void Outer::Inner::three() { ... }

Is there some way the Outer may be omitted without defining at the point of declaration, perhaps through use of namespaces to become:

void Inner::one() { ... }
void Inner::two() { ... }
void Inner::three() { ... }
  • 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-04T16:20:18+00:00Added an answer on June 4, 2026 at 4:20 pm

    I haven’t tried this (no compiler here) specifically, but I would hazard a guess that if you’re working with an inner class, like ::iterator, you could probably do:

    using outerclass::innerclass;
    

    and then do:

    innerclass::foo() { /* def */ }
    

    assuming there isn’t a global with the same name as your inner class in the outer class’s scope.

    Also, you could definitely use a macro, and could possibly use a typedef (not sure, but worth a try).

    I’d say all this makes your code less readable and it’s a bad idea though regardless of how you work around it.

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

Sidebar

Related Questions

I can define default value in domain by this way : class ProcessingPriority {
How can I define an output file stream within a class, so that I
Now I research OOP-part of Scheme. I can define class in Scheme like this:
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
I'm stuck. I'm trying to dynamically define a class method and I can't wrap
I often have a class defined and I also define another class that is
I'm trying to add another restriction on a method within a generic class. Is
I can define church numerals fairly easy using scheme: > (define f (lambda (x)
In HTML/CSS you can define a style which can be applied to many types
In C# you can define delegates anonymously (even though they are nothing more than

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.