Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Simple (I hope) question about pointers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Rottbott   Members   -  Reputation: 145

Like
Likes
Like

Posted 22 July 2001 - 02:23 AM

Hi, Can someone tell me how I can find out the pointer to an object from within that object''s constructor? So...: // Constructor for ''Object'' class Object::Object(void) { Object * PointerToMe = ???; } Thanks! Rottbott

Sponsor:

#2 sympathy   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 July 2001 - 02:42 AM

class Object
{
private:
Object *oInstance;
public:
Object(void);
};

Object::Object(void)
{
Object *oInstance = this;
}

A class definition has one set of methods used for all instances of that class. So in order to differentiate between instances an invisible pointer known as this stores the invoking object. So pretend I do this:

int main(void)
{
Object oMain;
return 0;
}

oMain is invoking the constructor, so it's constructor will take this (referring to oMain), and assign it to oInstance pointer. Hope this helped. Good luck.

Edited by - sympathy on July 22, 2001 9:43:34 AM

#3 Rottbott   Members   -  Reputation: 145

Like
Likes
Like

Posted 22 July 2001 - 03:41 AM

Excellent, thanks, I think I''ve got it working . Thanks again!


Rottbott




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS