Thread: problem with classes and pointers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717

    problem with classes and pointers

    WARNING: Not very clean code xP

    Well, I have this class called player.
    Code:
    class player : public character{
    
    public:
    	player();
    	~player();
    
    	float speed;
    
    private:
    	//hgeQuad
    
    };
    And then I have this class called character.

    Code:
    class character {
    
    public:
    	character();
    	~character();
    
    	float x, y;
    	static const int gravityPull = 1;
    
    	void gravity();
    	bool gravEffected();
    
    };
    And in the main.cpp file I call player* P1, this crashes the game, and I've had laods of problems, when I call it as a pointer, but not when I call it like; player P1, why is this?
    I still havn't figured out the differences between the two calls...
    The thing I'm having problem with is the x and y from character, by the way.
    Thanks in advance
    Last edited by Akkernight; 02-20-2009 at 02:52 PM.
    Currently research OpenGL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Q: Pointers to Classes '->' notation
    By Howie17 in forum C++ Programming
    Replies: 2
    Last Post: 12-12-2008, 10:09 AM
  2. Replies: 12
    Last Post: 12-31-2007, 06:59 AM
  3. two-dimensional dynamic array of pointers to classes
    By Timo002 in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 06:18 AM
  4. Pointers to Classes || pointers to structures
    By C++Child in forum C++ Programming
    Replies: 24
    Last Post: 07-30-2004, 06:14 PM
  5. Help With pointers in classes.
    By indigo0086 in forum C++ Programming
    Replies: 12
    Last Post: 10-10-2002, 02:03 PM

Tags for this Thread