'MathUtil' followed by 'int' is illegal (did you forget a ';'?)

This is a discussion on 'MathUtil' followed by 'int' is illegal (did you forget a ';'?) within the C++ Programming forums, part of the General Programming Boards category; While trying to run the code below: Code: #ifndef DTW #define DTW #include <iostream> #include<vector> #include<algorithm> #include<cmath> #include <deque> #include ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    1

    'MathUtil' followed by 'int' is illegal (did you forget a ';'?)

    While trying to run the code below:

    Code:
    #ifndef DTW
    #define DTW
    
    #include <iostream>
    #include<vector>
    #include<algorithm>
    #include<cmath>
    #include <deque>
    #include <sstream>
    #include <windows.h>
    
    typedef double floattype;
    
    using namespace std;
    
    class MathUtil {
    	public:
    		static inline int min (int x, int y ) { return x < y ? x : y;}
    		static inline int max (int x, int y ) { return x > y ? x : y}
    };
    I get bunch of errors:

    1>d:\dtw\dtw\dtw.h(33) : error C2062: type 'int' unexpected
    1>d:\dtw\dtw\dtw.h(33) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    1>d:\dtw\dtw\dtw.h(33) : error C2143: syntax error : missing ')' before '}'
    1>d:\dtw\dtw\dtw.h(33) : error C2143: syntax error : missing '}' before ')'
    1>d:\dtw\dtw\dtw.h(33) : error C2059: syntax error : ')'
    1>d:\dtw\dtw\dtw.h(33) : error C2143: syntax error : missing ';' before '}'
    1>d:\dtw\dtw\dtw.h(33) : error C2238: unexpected token(s) preceding ';'
    1>d:\dtw\dtw\dtw.h(34) : error C2628: 'MathUtil' followed by 'int' is illegal (did you forget a ';'?)

    Can anyone help me to solve this problem?

    Thanx in advance!!

  2. #2
    Registered User jdragyn's Avatar
    Join Date
    Sep 2009
    Posts
    93
    Looks to me like the compiler doesn't know what #include<vector> is (and likely the next couple of lines).

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Line 33..? The code you posted doesn't have 33 lines. There's a semicolon missing in max. Other than that it looks fine to me. If it really reports errors about this piece of code, my best guess is that you're trying to commpile it with a C compiler. What compiler are you using?

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The names "min" and "max" are dangerous, because windows.h, in Microsoft's most idiotic move in the history of the WinAPI, defines function-style macros by those names.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  2. getting a headache
    By sreetvert83 in forum C++ Programming
    Replies: 41
    Last Post: 09-30-2005, 05:20 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 05:05 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 04:26 PM

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