Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Making Forward Declaration Class's enum Member Visible

Making Forward Declaration Class's enum Member Visible

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yccheok
    wrote on last edited by
    #1

    hello all, how can i make, a forward declaration class's enum member, being visible by another class? consider the following case, ---------------------------- dog.h ---------------------------- #ifndef DOG_H #define DOG_H // class forward declaration. class cat; class dog { public: enum dog_enum { d0, d1, d2 }; void speak(cat *c); }; #endif ---------------------------- cat.h ---------------------------- #ifndef CAT_H #define CAT_H #include "dog.h" class cat { public: void speak(dog *d, dog::dog_enum e); }; #endif The above cat and dog just work fine. Now, let me create an enum type for cat too. ---------------------------- dog.h ---------------------------- #ifndef DOG_H #define DOG_H // class forward declaration. class cat; class dog { public: enum dog_enum { d0, d1, d2 }; // OPPS! HOW DO WE FORWARD DECLARE ENUM??? void speak(cat *c, cat::cat_enum e); }; #endif ---------------------------- cat.h ---------------------------- #ifndef CAT_H #define CAT_H #include "dog.h" class cat { public: enum cat_enum { c0, c1, c2 }; void speak(dog *d, dog::dog_enum e); }; #endif My question is, how can "dog" see the cat_enum, which is re-inside cat? I was understand that forward declaration for enum is not allowed in c++. Is there any workaround for this? Thank you very much

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups