Getting Address of Current Instance

Ok so my situation is this: I have a static member of my class which happens to be an array of pointers to my class type


1
2
3
4
5
6
7
class sprite
{
private:
    //
    //
    static sprite* addr[maxsprites];
    // 


And in my constructor I find the first empty array member- make that instance's ID (of a sorts) that number. My problem is I want to add the address of the particular instance of my class to the static array of sprites. How do I get the address of the current instance so i can pass it to my array?



[I won't post my whole code as it's nearly 2000 lines long, however if you want to see why I want to implement this I would be glad to show you]
The "this" pointer is the address of the object.

1
2
3
4
5
6
7
8
#include <iostream>

class Foo {
   public:
      void print_my_address() {
          std::cout << this << std::endl;
      }
};

Last edited on
For serious! Oh my gosh, thank you for that!
Topic archived. No new replies allowed.