"class" errors!

This is a discussion on "class" errors! within the Game Programming forums, part of the General Programming Boards category; I'm getting really angry with this! I want to create a class for my OpenGL Pong game! When I do ...

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

    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
    {
    public:
    void setp(GLfloat x, GLfloat y);

    private:
    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?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    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
    Posts
    14
    You cannot call a function from a global position in your code.

    Put

    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, 11:50 AM
  2. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 03: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, 09:18 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM

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