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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. enum

enum

Scheduled Pinned Locked Moved C / C++ / MFC
questionlearning
4 Posts 3 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.
  • K Offline
    K Offline
    klutez123
    wrote on last edited by
    #1

    how do I input info entered for a enumerated object? enum typeofbook {fiction, nonfiction, reference, pond}; I'm trying to prompt the user which type of book they are entering information for. Any ideas would be appreciated. thanks

    D 1 Reply Last reply
    0
    • K klutez123

      how do I input info entered for a enumerated object? enum typeofbook {fiction, nonfiction, reference, pond}; I'm trying to prompt the user which type of book they are entering information for. Any ideas would be appreciated. thanks

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Your question is not very clear.

      cout << "Which type of book... (1=fiction, 2=nonfiction, 3=reference, 4=pond)";
      int nType;
      cin >> nType;
      switch (nType)
      {
      case 1:
      break;
      ...
      }


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      K 1 Reply Last reply
      0
      • D David Crow

        Your question is not very clear.

        cout << "Which type of book... (1=fiction, 2=nonfiction, 3=reference, 4=pond)";
        int nType;
        cin >> nType;
        switch (nType)
        {
        case 1:
        break;
        ...
        }


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        K Offline
        K Offline
        klutez123
        wrote on last edited by
        #3

        I put enum typeofbook {fiction, nonfiction, reference, pond}; in a structure which is then declared the structure as books. I am asking the user which type of book he is entering information for, 1 fiction, 2 nonfiction, 3 reference, 4 pond. Once they enter either the number or name for type of book, I need to cin>> the information or something so I can store into a text file.

        M 1 Reply Last reply
        0
        • K klutez123

          I put enum typeofbook {fiction, nonfiction, reference, pond}; in a structure which is then declared the structure as books. I am asking the user which type of book he is entering information for, 1 fiction, 2 nonfiction, 3 reference, 4 pond. Once they enter either the number or name for type of book, I need to cin>> the information or something so I can store into a text file.

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          enum are only an internal semantic representation of an integer value. you will store the integer value; not it's "representation" if a user enters 1 ( in the enum is fiction ) it will be stored as 1. pseudo code : you can either directly do something like : typedef enum {fiction, nonfiction, reference, pond} typeofbook; typeofbook myBookType; int i; cin>>i; myBookType = (typeofbook) i;


          Maximilien Lincourt Your Head A Splode - Strong Bad

          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