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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:32:43+00:00 2026-05-27T08:32:43+00:00

If we define two C++ classes. One is: abstract class A { public: enum

  • 0

If we define two C++ classes. One is:

abstract class A {
  public:
    enum E {F, G, H;}
};

Another is class B, and how I can use the enum E in class A then? Assuming both B and A are in the same namespace. I know in C# we can use something like:

A.E

directly, but seems that is not the case of C++.

  • 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-27T08:32:43+00:00Added an answer on May 27, 2026 at 8:32 am

    In C++, . and -> are for accessing a member of this particular instance of an A object. :: is for accessing things in the scope of class A. This includes statics, enums, and function pointers.

    So in C++ you want A::F or A::G if you want enum value.

    for the enum type you do A::E

    class A
    {
    public:
        enum E { F , G , H};
        virtual ~A() = 0; //a pure virtual function to make the class abstract
    };
    
    int main()
    {
        A::E x; // x is declared as the enum
        x = A::F; // x is assigned a particular enum value
    
        return 0;
    }
    

    Also to make the class abstract you provide a pure virtual function.

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

Sidebar

Related Questions

If two assemblies both define namespace A containing class A1 , then the two
I have need to use one of two custom file readers classes; one to
I'm trying to do the following, define two classes whose instances mutually reference one
How can I define a composite primary key consisting of two fields in SQL?
in bash I need to compare two float numbers, one which I define in
I have two classes, one inherited from the other. When I compile, I get
I need to define these two Properties to one of my linqclasses (Employee).. because
How to define a struct whose members can be accessed by any internal classes
I have two classes A and B. Many B's can have association with a
I have an abstract base class which acts as an interface. I have two

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.