Thread: pointeroma

  1. #1
    NotSoAvgProgrammer
    Join Date
    Jul 2007
    Location
    Virginia, U.S.
    Posts
    57

    pointeroma

    Hey guys, I'm making a class object, which is given a pointer to a class physics, which is has the option of taking a pointer to a funtion for key presses. Know I was thinking something like this.

    Code:
    class Physics3f
    {
    public:
    	physics3f(float, float, float);
    	void endable(std::string);   // differentiate between user, ai, free world
    	void disable(std::string);  // in order to change feature
    	void keyfunc(std::vector<float> (*KFptr)());// pointer to key function
    	...
    
    };
    
    class object3f
    {
    public:
    	object3fptr(float, float, float, *Physics3f);
    	...
    };
    Is that even on the right track?

    Thanks,

    Joe
    A quality job is not necessarily a *good* job. A quality job is, by definition, conformance to requirements. Therefore a *good* job, may not be a quality job.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Without knowing more about what you're trying to do, it looks OK to me.
    Although, one thing I usually do with function pointers is create a typedef for them so they're easier to use and read.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    class Physics3f
    {
    public:
    	physics3f(float, float, float);
    The language is case-sensitive, p does not equal P.
    "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

  4. #4
    NotSoAvgProgrammer
    Join Date
    Jul 2007
    Location
    Virginia, U.S.
    Posts
    57
    Ok, thanks, I just wanted to make sure it isn't like a horrible build plan. What I'm planning on doing is having class object hold control an object on the screen completely. Then physics, will let me differentiate between static, ai, and user objects, allowing me to enable different settings for each individual object, such as key handling for users, or static physics, for things like a box. I have now, decided to let object take a show function as well. This way I can have all objects in one, standard class, in which I can pull standard specs from (such as speed, velocity, width, etc.). This is the first time I've ever tried to implement something like this, so I just want to make sure that it's not a big "no no".


    Thank you for your help,


    Joe
    A quality job is not necessarily a *good* job. A quality job is, by definition, conformance to requirements. Therefore a *good* job, may not be a quality job.

Popular pages Recent additions subscribe to a feed