#define and headers
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: #define and headers

  1. #1
    Join Date
    Feb 2009
    Posts
    135

    #define and headers

    When I use a #define for a header file, do I use it in the header file or in the associated .cpp file?

    My switch statements:

    Code:
    		case NAME:
    			cout << endl << "getline(cin, student.name);"
    				 << endl;
    			break;
    		case MIDTERM:
    			cout << endl << "student.midterm = GetIntInput()" 
    				 << endl;
    			break;
    		case FINAL:
    			cout << endl << "student.final = GetIntInput()"
    				 << endl;
    			break;
    		case HOMEWORK:
    			cout << endl << "Add-Edit_Homework();"
    				<< endl;
    			break;
    		case TESTS:
    			cout << endl << "Add-Edit_Tests();"
    				 << endl;
    			break;
    		case QUIZZES:
    			cout << endl << "Add-Edit_Quizzes();"
    				 << endl;
    			break;
    		case PROJECTS:
    			cout << endl << "Add-Edit_Projects();"
    				 << endl;
    			break;
    		}
    Are giving a ": not found before ;" error, and that is the only thing I can surmise to be wrong.

  2. #2
    Join Date
    Apr 2004
    Posts
    102

    Re: #define and headers

    If you have more than one .cpp file that uses the macros, put it in the .h

    Although, if you are using it for a switch like this, it might be better to use an enum and group them together. It will save you some typing.

  3. #3
    Join Date
    Feb 2009
    Posts
    135

    Re: #define and headers

    Well, the fact that it isn't working worries me. But I'll check up on the syntax of an enum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center