Thread: "class" errors!

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001

    Angry "class" errors!

    I'm getting really angry with this! I want to create a class for my OpenGL Pong game! When I do this:

    class P
    void setp(GLfloat x, GLfloat y);

    GLfloat p1x;
    GLfloat p1y;
    }; P PDAT[2];

    void P::setp(GLfloat x, GLfloat y)
    p1x = x;
    p1y = y;

    PDAT[0].setp(0.0f, 0.0f);

    When I do this, it returns:

    33 w32p3d.cpp
    syntax error before `.'

    Why does it do this?


    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    Registered User
    Join Date
    Aug 2001
    You cannot call a function from a global position in your code.


    PDAT[0].setp(0.0f, 0.0f);

    inside main() or some other function and it will most likely work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  4. Help me with these errors... :-(
    By major_small in forum C++ Programming
    Replies: 6
    Last Post: 09-07-2003, 08:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM