Thread: Enumeration question?

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    26

    Enumeration question?

    This is a problem with calling a function.

    I have declared the following:

    enum height { high, low, equal }
    void errormsg ( errors )

    ////////////////////


    void errmsg ( height )
    {
    switch ( errors )
    case high:
    cout << "The height is too high /n"
    case low:
    cout << "The height is too low./n"
    .
    .
    .
    How do I write the call to the function errmsg? I'm having trouble filling in the middle. Also, If I have a problem with the declaration or function - Thanks for the advice.

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Try this -

    Code:
    #include <iostream>
    
    using namespace std;
    
    enum height { high, low, equal };
    void errmsg ( height errors ); 
    
    int main()
    {
    	height h = high;
    
    	errmsg(h);
    
    	return 0;
    }
    
    void errmsg ( height errors ) 
    { 
    	switch ( errors ) 
    	{
    	case high: 	cout << "The height is too high.\n";break; 
    	case low: cout << "The height is too low.\n" ;break;
    	}
    }
    zen

  3. #3
    Unregistered
    Guest

    using namespace std;

    Question on the reply:

    What does this line do?

    using namespace std;

  4. #4
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    It brings all of the std namespace into global scope, so that anything contained within it may be used without the std prefix.
    zen

  5. #5
    Dual
    Guest
    What's an enum? I've never come across that before..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enumeration Issues
    By cdn_bacon in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2007, 02:26 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM