Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

12
Can someone tell me how was I supposed to access this enum?
Post Flair (click to view more posts with a particular flair)
Post Body

Hi all. I just did an interview and I'm a bit annoyed that I wasted 1/3rd of the allocated time because I was stuck on accessing an enum inside of a struct. It was a while since I used c . I don't think I can go into specifics of the problem.

Basically there was a struct, an enum inside the struct with a few states, and a function inside the struct. I was then supposed to write the functionality for the function outside of the struct. The problem is, I couldn't figure out in writing the functionality for the function on how to access the enum for a switch statement. Assuming the struct name is x, and the enum name is y, I tried switch(x::y), wasn't working, and other variations, usually " expected unqualified-id before ')' ". Maybe my whole approach was wrong, I don't know. There is NO main anywhere.

struct x{
    enum states { // not a enum class
        state1
        state2
    }

    x::somefunction(bool x) // dont remember exactly how declared here or below
}

x::somefunction(bool x){
    // some of my code
    switch(states) // This is where I had trouble
}

What I ended up doing was adding the enum as one of the function parameters at the end because I was about to run out of time. I didn't even have time to test, just saw it compiled fine. It wasn't clear whether I could change the already given template, so not sure if that was even allowed.

So how should I accessed that enum? Thanks. Really disappointed because I probably ruined my chances.

Author
User Disabled
Account Strength
0%
Disabled 2 months ago
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
3,201
Link Karma
40
Comment Karma
3,131
Profile updated: 3 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
3 years ago