this Questions

1

I wrote the following program in C++23 that compiles with gcc and clang but is rejected by msvc. I want to know is this well-formed or ill-formed etc as per the standard. Live demo struct C { void...

2

Solved

In order to make this code with C++11 reference qualifiers work as expected I have to introduce a std::move(*this) that doesn't sound right. #include<iostream> struct A{ void gun() const&amp...
Interrupter asked 15/8, 2014 at 21:48

8

Solved

I have this method that I want to use $this in but all I get is: Fatal error: Using $this when not in object context. How can I get this to work? public static function userNameAvailibility() { ...
Moten asked 18/2, 2010 at 6:18

1

Solved

I'm working on the following code snippet: #include <iostream> #include <vector> class myclass { public: myclass() { std::cout << this << std::endl; } }; int main() ...
Goldy asked 18/12, 2023 at 21:41

11

Solved

class Sub { static int y; public static void foo() { this.y = 10; } } I understand that this represents the object invoking the method and that static methods are not bound to any object. But...
Bul asked 26/7, 2012 at 7:36

4

Solved

I try to find address of this pointer, but this code is showing a strange error: #include <iostream> using namespace std; class Base { public: void test() { void *address_of_this =&t...
Barter asked 2/2, 2012 at 15:26

3

Solved

I'm attempting to capture the this pointer within a lambda function that serves as the default parameter for a method. My goal is to invoke a method of this class from within the lambda, which nece...
Zoometry asked 8/9, 2023 at 8:20

8

Solved

I've come across several instances of C# code like the following: public static int Foo(this MyClass arg) I haven't been able to find an explanation of what the this keyword means in this case. ...
Loraineloralee asked 11/5, 2009 at 5:5

2

Solved

So in my header file I have these two variables declared as private private: char* data; int len; and give this to access it int length() const { return len; } Then in my cpp file I am ...
Envelopment asked 23/11, 2014 at 9:32

15

Solved

I have a constructor function which registers an event handler: function MyConstructor(data, transport) { this.data = data; transport.on('data', function () { alert(this.data); }); } // Mo...
Money asked 29/11, 2013 at 6:13

12

Solved

class PlayerControls extends React.Component { constructor(props) { super(props) this.state = { loopActive: false, shuffleActive: false, } } render() { var shuffleClassName = this.state....
Vitascope asked 28/11, 2015 at 16:30

16

What's the difference between var A = function () { this.x = function () { //do something }; }; and var A = function () { }; A.prototype.x = function () { //do something };
Digestif asked 22/11, 2008 at 4:39

6

Solved

first post here, I come in peace :) I've searched but can't quite find what I'm after. I am trying to manipulate the selected option of a select box. Can someone please explain why this works: $(...
Guadiana asked 22/3, 2010 at 17:4

2

Solved

Since std::function can hold member functions, so it must store a pointer to the object instance somewhere. How can I fetch the this pointer from a std::function that holds a member function?
Marielamariele asked 1/4, 2013 at 16:53

3

Solved

I create a function somewhere and I bind it to this so that I can use the parent block's meaning of this as the value of this within the function. For example: var foo = function() { // some stuf...
Machuca asked 14/4, 2018 at 18:50

5

I'm trying to understand TypeScript decorators (specifically for properties), and I came up with the following code based on some examples I've seen: decorator.ts export function logProperty(targ...
Onlybegotten asked 23/8, 2017 at 4:53

7

Solved

I tried this: // mod.js var a = 1; this.b = 2; exports.c = 3; // test.js var mod = require('./mod.js'); console.log(mod.a); // undefined console.log(mod.b); // 2 console.log(mod.c); // 3, so this...
Formication asked 28/2, 2012 at 2:56

4

Solved

I get confused on a JavaScript this reference situation. I am working on a code that I declare function inside an object method. (The reason is to tidy up code inside an object method, while keepi...
Estimative asked 5/4, 2013 at 10:25

1

Solved

Pre-c++20, the this pointer is captured in [=] implicity. So what's the reason that c++20 decided that user should write [=, this] to capture this pointer explicitly, I mean, without this change, t...
Bloomers asked 1/8, 2022 at 16:27

9

Look into the following code: public class ClassA { private boolean ClassAattr = false; public ClassA() { ClassAHandler handler = new ClassAHandler(this); } } public class ClassAHandler ext...
Foghorn asked 10/3, 2010 at 18:17

22

Normally, I use this in constructors only. I understand that it is used to identify the parameter variable (by using this.something), if it have a same name with a global variable. However, I d...
Chapiter asked 16/9, 2010 at 15:14

24

Solved

I already know that apply and call are similar functions which set this (context of a function). The difference is with the way we send the arguments (manual vs array) Question: But when should I u...
Photocurrent asked 16/3, 2013 at 21:40

7

Solved

I just came across an interesting situation in JavaScript. I have a class with a method that defines several objects using object-literal notation. Inside those objects, the this pointer is being u...
Bernadette asked 25/9, 2008 at 15:25

2

Solved

I'm writing a small JavaScript game framework and often use objects' properties, like this.depth = this.y; But these this'es are quite annoying @_@. Is there a way to write just… depth = y; …...
Impound asked 15/2, 2015 at 11:2

3

Solved

I'm learning to use the new Dart extension methods. I'm doing this: extension StringInsersion on StringBuffer { void insertCharCodeAtStart(int codeUnit) { final end = this.toString(); this.c...
Throwaway asked 5/1, 2020 at 12:4

© 2022 - 2024 — McMap. All rights reserved.