Help with a missing ';' error

This is a discussion on Help with a missing ';' error within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm having a problem with a line of code that doesn't seem to be working right. I have no ...

  1. #1
    UCF Mystic_Skies's Avatar
    Join Date
    Oct 2004
    Posts
    33

    Help with a missing ';' error

    Hello,
    I'm having a problem with a line of code that doesn't seem to be working right. I have no idea why it keeps telling me I have a missing ';' before '-'. Any help would be appreciated. Here's the error in Visual Studio:


    : error C2143: syntax error : missing ';' before '-'
    : error C2433: 'Point::Vector' : 'inline' not permitted on data declarations
    : error C2501: 'Point::Vector' : missing storage-class or type specifiers


    Code:
    #include <iostream>
    #include <GL/glut.h>
    
    using namespace std;
    
    class Point{
    public: 
    	float  x, y, z; 
    	inline Point  (){};
    	inline Point  (float, float, float);              // initialization of vectors
    	inline Point  operator+ (const Point &p) const;   // addition of points
    	inline Vector operator- (const Point &p) const;   // subtraction of points (returns vector)	<-- ERROR
    }; 
     
    class Vector{
    public:
    	float x, y, z, w;
    	inline Vector (){};
    	inline Vector (float, float, float);             // initialization of vectors
    	inline Vector operator+ (const Vector &v) const; // addition of vectors
    	inline Vector operator- (const Vector &v) const; // subtraction of vectors
    	inline Vector operator* (const Vector &v) const; // multiplication of vectors
    	inline Vector operator* (const Point &p)  const; // multiplication of vector and scalar
    	inline Vector operator! () const;                // negation of vectors
    };
    
    int main(int argc, char **argv)
    {
    	return 0;
    }// end main

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Try moving your Vector related code so that it comes before your Point related code.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Quote Originally Posted by hk_mp5kpdw
    Try moving your Vector related code so that it comes before your Point related code.
    That will not work because Vector also uses the then undefined class Point. You have the same problem no matter the order.

    Leave your code the way it is and above your Point class just forward declare the Vector class like this:

    Code:
    class Vector;
    
    class Point{
      //etc
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Quote Originally Posted by MrWizard
    That will not work because Vector also uses the then undefined class Point. You have the same problem no matter the order.

    Leave your code the way it is and above your Point class just forward declare the Vector class like this:

    Code:
    class Vector;
    
    class Point{
      //etc

    Oops... yeah I didn't see that reference to the Point object in the Vector class.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    UCF Mystic_Skies's Avatar
    Join Date
    Oct 2004
    Posts
    33
    Thanks! It worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM

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