Search:

Type: Posts; User: Canadian0469

Page 1 of 3 1 2 3

Search: Search took 0.00 seconds.

  1. Damn! I noticed that just before you posted and...

    Damn! I noticed that just before you posted and was hoping I could change it in time! How embarassing lol sorry
  2. deleting and re-assigning a global variable pointer

    Hi,

    I have a global variable
    Game * game;

    in main I have game = new Game();

    and I have another function which monitors the progress of the game and if the current level is completed then I...
  3. Thank you everyone for your ideas. I ended up...

    Thank you everyone for your ideas. I ended up doing as C_ntua suggested which is to simply maintain a single global variable which is a pointer to game.

    Magos, I know about Singletons and actually...
  4. Yeah I realized that... What I ended up doing was...

    Yeah I realized that... What I ended up doing was I created a class Game which has pointers to all the characters as members and I have one global variable of type Game in my driver which I use to...
  5. Best way to avoid using global variables

    Hi,

    I'm working on a pacman clone in C++ and I'm using GLUT for the graphics. While I was coding the game, I was using global variables to pointers to objects pacman which is of type Pacman, and 4...
  6. thanks I got so lost in playing with inheritance...

    thanks I got so lost in playing with inheritance within the pacman class that I lost sight of the fact that it's totally normal to have mutators and accessors be public haha. thanks for bringing me...
  7. Accessing a protected member declared in parent class

    Hi,

    I have a base class character, a child class pacman, and a file called manager.cpp which contains main and serves to manage the characters in the game while the game is in progress.

    In...
  8. Initializing constant object member of a class

    I've got a class Pacman declared as follows:


    #ifndef PACMAN_H
    #define PACMAN_H

    #include "Character.h"
    #include "Map.h"

    class Pacman : public Character
  9. DOH! ...right thanks!

    DOH!

    ...right

    thanks!
  10. Right, but for the speeds, the compiler complains...

    Right, but for the speeds, the compiler complains (I'm using VC++ 2005) if I move the constant speed definitions into the class declaration since they are not of integral types.

    If I can't declare...
  11. Thanks laserlight, you're always so helpful! I...

    Thanks laserlight, you're always so helpful!
    I did include a virtual destructor for base class character though didn't I?
    I have:
    virtual ~Character();

    isn't that the virtual destructor??
    ...
  12. Doesn't a derived class inherit the private member of its parent?

    Hi all,

    I've got a base class Character and a class Pacman derived from Character.
    Character is defined as follows:



    #ifndef CHARACTER_H
    #define CHARACTER_H
  13. Is it required to provide default definitions for virtual functions in a base class?

    1. Are we required to provide default definitions for (non-pure) virtual functions in a base class? My intuition tells me yes because from what I understand a base class with virtual functions (and...
  14. Replies
    1
    Views
    675

    Returning a pointer

    Hi,

    I have a real beginner question for you all.


    double * GetSalary()
    {
    double salary = 26.48;
    double *HourlySalary = &salary;
  15. Oh ok so I had the wrong idea. Thanks for...

    Oh ok so I had the wrong idea. Thanks for clearing that up for me Kurt, that one sentence totally demystified it for me!
  16. Replies
    4
    Views
    1,685

    Right... thanks!

    Right... thanks!
  17. Oh ok I think I get it now... So the const in...

    Oh ok I think I get it now...

    So the const in the function declaration that follows the parameter list is not just a promise that the function itself won't modify the arguments but it is also a...
  18. Ok well I'm trying to make sense of these two...

    Ok well I'm trying to make sense of these two lines my professor wrote in an example program to simulate STL vectors:



    T & operator[](size_type i) { return data[i]; }
    const T &...
  19. Replies
    4
    Views
    1,685

    Okay so in this example, where I'm simulating STL...

    Okay so in this example, where I'm simulating STL vectors with
    limit = a pointer to the memory location AFTER the last available one
    avail = a pointer to the next available memory location
    ...
  20. Replies
    4
    Views
    1,685

    Pass by constant reference

    Pass by constant reference ensures that the argument won’t be modified BY THE FUNCTION. So if in the function you push the argument onto a vector then return from the function, you then have the...
  21. Effect of const in a function declaration

    Hi,

    To include const in a function declaration, does that actually ensure that the function does not modify the arguments passed to the function? Or is it just a sort of promise to the user from...
  22. Assigning an object variable to a constant reference

    Hi,

    Can someone please explain to me exactly what happens when line
    Rational result = left;
    is executed?


    Rational operator+ (const Rational & left, const Rational & right)
    {
    Rational...
  23. Okay, well if it's not possible, can anyone think...

    Okay, well if it's not possible, can anyone think of a way that I might be able to print a line e.g.
    3.8045e+00 5.3859e+34 5.3853e+53

    i.e. maybe is there a way where I can print columns of...
  24. Controlling precision after E in sci notation

    Hi,

    I'm trying to print a number but it's printing like this:
    1.0000e+000
    but I want to only show two 0's after the e+, do you know of any manipulators or something I could use to restrict the...
  25. Replies
    11
    Views
    954

    What a great way to start the semester... That...

    What a great way to start the semester... That was seriously my first example.

    Anyway, thanks for the help guys! I just wanted to make sure I was tracing it correctly and that it was actually an...
Results 1 to 25 of 52
Page 1 of 3 1 2 3