Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Whats wrong with this class?

  1. #1
    Member Newbie
    Join Date
    Feb 2002
    Posts
    35

    Whats wrong with this class?

    This is killing me what is wrong with this definition?


    #ifndef _MGAME_H
    #define _MGAME_H

    #include "main.h"
    #include "MCamera.h"

    class MGame
    {
    public:

    MGame();
    ~MGame();

    void draw();
    void resizeWindow(int w, int h);
    void keyboard( int key, int x, int y);
    void keyboardUp( int key, int x, int y);

    MCamera mCamera;
    };

    #endif

  2. #2
    Member Newbie
    Join Date
    Feb 2002
    Posts
    35

    Re: Whats wrong with this class?

    it says: declaration syntax error
    MGame.h line 7 class MGame

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Whats wrong with this class?

    I suspect the error is really in MCamera.h, towards it end.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    fu,ck,you
    Posts
    3

    Re: Whats wrong with this class?

    EVERYTHINK IS PUBLIC AND THAT IS STUPID MAKE IT A STRUCT THEN

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Whats wrong with this class?

    Mister 455h*L3, take it easy on your attitude there... Provide something more helpful than that...

    ///////////////////////////////////////

    What is your error message...
    There is nothing wrong with the class that I see... But you maybe including the a header somehwere twice, I dont know...

    Try putting

    #pragma once

    in the very begining of you code...
    Post your error messages...

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: Whats wrong with this class?

    I agree with dfey. I think you're missing a semicolon after your class prototype in <dicknose>.h. Keep in mind that the program you're actually compiling is the concatenation of the header and source files, so syntax errors in the header file _will_ fall through the the source.

    and to that 4hackerleetidiot guy: struct IS just a public class. they are interchangable, so why should he change his decl to struct? it's semantically the same thing, anyway. (struct in C++ is just class with a default of public, rather than a class with a default of protected).

    cheers
    JOhn

  7. #7
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Whats wrong with this class?

    Another thing is that he may not want to have the functions be accesible for anybody eccept for object instances of the class >>>>>>>>>>><<<<<<<<<<<<<<
    So, since structs cant have function declarations in them, a class is the solution!
    So, I think there is more than just a simple "make it a struct" issue here...
    <<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>

    Besides... escozooz, why dont you post the code of the header file that maybe giving you problems...

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Whats wrong with this class?

    ...since structs cant have function declarations in them...
    Try compile this piece of C++ code, and think about what you just said.
    Code :
    #include <iostream>
    using namespace std;
    struct foo
    {
        void bar(void) {cout << "Hello world!" << endl;}
    };
    void main(void)
    {
        foo f;
        f.bar();
    }
    As john said, the only, and I mean ONLY difference between a class and a struct is: A struct defaults to public members/inheritance, while a class defaults to private. There are NO other differences.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Whats wrong with this class?

    OK... I guess you learn something new everyday...

    I was taught that you could not mix function with regular variables in a struct, so the solution were classes... I never tried mixing them both in a struct, since I took it for granted...

    Well, thanx...

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Whats wrong with this class?

    If you were programming pure C, you'd be right Mancha. In C++, however, it's like John and Bob said.. the only difference is default visibility.
    Deiussum
    Software Engineer and OpenGL enthusiast

Page 1 of 2 12 LastLast

Similar Threads

  1. Not sure whats wrong
    By Discoloda in forum OpenGL: GLSL
    Replies: 0
    Last Post: 10-31-2005, 08:58 AM
  2. Whats wrong with the picking?
    By Bilyboy in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-08-2004, 05:25 AM
  3. Whats wrong with this ?
    By freestyler in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-27-2002, 05:11 AM
  4. Whats wrong with my code? :(
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-17-2001, 09:24 AM
  5. Whats wrong with this!!
    By imported_Sean in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-29-2001, 03:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean