Add Announcement Here
- Index
- » Development
- » C++
- » Using this pointer in the initialiser...
Page:
1
Using this pointer in the initialiser list
Using this pointer in the initialiser list
You know, it's fun like the constructor/destructor that makes me get out of bed to code c++. There is all sorts of fun stuff that can happen, for instance if you use a virtual function during destruct/construct it may be possible for the parent to call the child's function, and because the child has already been destroyed, you're fucked.
Now the prompt for this post came when making nested classes have access to their containing class:
Code:
class topNest{
protected:
void callback(); // innerNest can use.
class innerNest{
public:
innerNest(topNest &parent);
private:
topNest &mParent;
};
friend class innerNest;
};
continued...
Edited By: stu
Wed-10-12 16:52:51
Wed-10-12 16:52:51
Administrator has disabled public posting
Re: Using this pointer in the initialiser list
As we know, using the 'this' pointer is dangerous during construct/destruct, but c++ lets you ride the tiger if you choose.
http://stackoverflow.com/questions/5058 … ation-list
Administrator has disabled public posting
Page:
1
- Index
- » Development
- » C++
- » Using this pointer in the initialiser...
Board Info
- Board Stats:
- Total Topics:
- 225
- Total Polls:
- 0
- Total Posts:
- 424
- Posts this week:
- 1
- User Info:
- Total Users:
- 7
- Newest User:
- ian96
- Members Online:
- 0
- Guests Online:
- 22
- Most Active Users:
- stu, Ent, ian96, Andy, Administrator, welkomfor, zerg
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked




























