this-pointer

is using *this a good idea?

Hi, I'm not sure if return *this is the only way we could return an instance of a class who called a member function? Reason why I asked is because our instructor told us to avoid using pointers if necessary and I'm wondering if this is a case where the only necessary way to do it is by returning the this pointer. I'm working wit...

delete this pointer behaviour in g++

#include <stdio.h> class Foo { public: Foo(char x); Foo(char x, int y); ~Foo(); void abc(); void dev(); }; void Foo::dev() { printf("inside dev \n"); } void Foo::abc() { printf("inside abc \n"); delete this; dev()...

Use super class's address/pointer in initialization list

context 1: class D : public B1, public B2{}; context 2: B2 takes B1 to initialize: B2( B1 * ) //B2's constructor my question is in D's initialization list: D::D() : B1(), B2( ? )... What should be in ? I don't want to put " (B1*)this " in the ? place, because it's no good to use "this" in initialization list. And since B1 part ha...

Using a ref Parameter with the this Keyword?

Is there a way to force the this keyword to act as a ref argument? I would like to pass in a visitor that modifies multiple properties on the object, but this only wants to act like a value parameter. Code in Object: public void Accept(Visitor<MyObject> visitor) { visitor.Visit(this); } Code in Visitor: public void Visit(ref Vis...

Cross-reference js-object variables when creating object

Summary: I want to know if it is possible to do something like this: {a: 'A',b: this.a} ...by using some other pointer like {a: 'A',b: self.a} or {a: 'A',b: own.a} or anything else... Full question: I'm trying to extend MyBaseModule using Ext.extend, and need to cross-reference values in the extension object passed to Ext.extend()....

How to get Javascript Select box's selected text

This things works perfectly <select name="selectbox" onchange="alert(this.value)> But I want to select the text. I tried in this way <select name="selectbox" onchange="alert(this.text)> It shows undefined. I found how to use dom to get text. But I want to do this in this way, I means like using just this.value. ...

When to use THIS keyword when working with controls on form in C#

I am still far away from mastering C# but child in me pushing me to programming day by day. When I making WinForm application I want to change and use lot of controls pragmatically. What I do not understand is, When I need to set this.control keyword and when I should use just control. Sample: If I want to cgange text of my label I can w...

Why is it legal to pass "Me" ByRef in VB.NET?

I was shocked just a moment ago to discover that the following is legal (the C# equivalent is definitely not): Class Assigner ''// Ignore this for now. Public Field As Integer ''// This part is not so weird... take another instance ByRef, ''// assign it to a different instance -- stupid but whatever. ' Sub Assign(By...