Enumeration question?

This is a discussion on Enumeration question? within the C++ Programming forums, part of the General Programming Boards category; This is a problem with calling a function. I have declared the following: enum height { high, low, equal } ...

  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
    zen
    zen is offline
    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
    zen
    zen is offline
    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, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21