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

The Archive Base Latest Questions

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

The struct is as follows: struct padData { enum buttonsAndAxes { select, start, ps

  • 0

The struct is as follows:

struct padData 
{
    enum buttonsAndAxes
    {
        select,
        start,
        ps
    };
};

The object of the struct:

padData        pad;

I am accessing this enum as follows:

printf ("\n%d", pad.buttonsAndAxes[0]);

Error:

error: invalid use of ‘enum padData::buttonsAndAxes’

Then, I tried:

printf ("\n%d", pad::buttonsAndAxes[0]);

Error:

error: ‘pad’ is not a class or namespace

Now what? Please guide.

Compiler: gcc version 4.5.0

EDIT 1:____________________________________

printf ("\nemit: %d", padData::(select)0);

results in:

error: expected unqualified-id before ‘(’ token

My aim is to fetch the word “select” through its value 0. How to achieve that? Also, is the word “select” a string?

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

    The enum values become names in the scope of the class. So you would use padData::select from outside the class, or just select from inside the class.

    In C++11 you can qualify the enumerators with the name of the enum, giving padData::buttonsAndAxes::select from the outside and buttonsAndAxes::select from inside.


    Printing the name of an enumerator is not easily done in C++, because the names are gone after compilation. You need to set up a table mapping the values to their strings by hand. If you don’t supply explicit values like in your example, you can simply use an array:

    enum buttonsAndAxes
    {
        select,
        start,
        ps
    };
    
    const char* buttonsAndAxesNames[] = {
        "select",
        "start",
        "ps"
    };
    

    And then you index into that array:

     printf("%s", buttonsAndAxesNames[select]);
    

    If you want some more sophisticated approach, you can find a bunch of tricks in previous questions.

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

Sidebar

Related Questions

I have a struct defined like follows as part of an object. I'm trying
I have a struct as follows, with a pointer to a function called length
I've got a structure as follows: typedef struct { std::wstring DevAgentVersion; std::wstring SerialNumber; }
In rpc.h, the GUID structure is declared as follows: typedef struct _GUID { DWORD
struct elem { int i; char k; }; elem user; // compile error! struct
I've declared a struct as follows: struct Hex { CGPoint center; CGPoint points[6]; CGFloat
Suppose I have a struct called Node as follows: struct foo { foo *next;
I have a struct defined as follows: template <typename T> struct data { int
In a C struct I have defined a function pointer as follows: typedef struct
I have a structure as follows: struct something{ char *string_member; }; now I created

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.