Questions tagged [member-variables]

A member variable is a member of a type and belongs to that type's state. (Contrast with a "local variable", defined inside a method.)

169 questions
1
vote
2 answers

Can I create a member variable that is a type parameter of a generic?

I have a lot of proxy classes around services, and all look (almost) the same. Can I reduce code duplication somehow by using a generics singleton class, that takes the Service and Port class as type parameters? This is my completely wrong code with…
towi
  • 21,587
  • 28
  • 106
  • 187
1
vote
2 answers

Set "zero" value to member variable

I'm having trouble understanding some C++ concepts. When is it appropriate to use a member pointer vs a member variable? Let's say I have a tree structure and thus a Node class. My intuition would be to use a variable for its Data and Edge (because…
Jawap
  • 2,463
  • 3
  • 28
  • 46
0
votes
0 answers

Link to member variable is incorrect

Problem overview: A member variable is correctly set in the setter but read from a wrong address in the getter. Project set up: I am using a microcontroller of the STM32F4 series. The project contains C- and C++-code. The latter is used for a GUI…
Ardian
  • 31
  • 1
  • 1
  • 6
0
votes
1 answer

Does a conditional wait for member variable update in JS?

I just have a basic question about order of execution in JS code. deleteAttachement({ cdId, paId: recordId }).then(response => { if (response) { this.existingFilesList = this.existingFilesList.filter(file =>…
0
votes
2 answers

Cpp Compile "error: unknown type name" when initializing object as member variable of other class

I'm new to C++. I am initializing a class object Node in another class LCache. When I try to compile my code, I get the following error: Line 22: Char 5: error: unknown type name 'left' left -> next = right; ^ Below is the code I have…
0
votes
1 answer

How can I set class member variable correctly from vector in C++

I'm trying to set a class member variable from STL vector in C++. But it doesn't work the way I want it to. The variable doesn't change, The variable is the same like before. Am I programming in the wrong way? Here's the code. #include…
World
  • 21
  • 3
0
votes
1 answer

can't access a member variable in struct array in struct

I am making a C program, which needs to access a struct array in a struct. The definition looks like below struct def_world { bool lock; char tilemap; def_tile tile[100][100]; struct def_tile { bool lock; char kind; def_obj *…
kim taeyun
  • 1,837
  • 2
  • 24
  • 49
0
votes
1 answer

How to get updated class variable value in Django

I'm having trouble getting the updated value of a class variable. When ConnectTestAPI is called after the p_request function is executed, the class variables which are result and orderNo should updated in the post function. Then I want to receive…
Jo Jay
  • 123
  • 1
  • 3
  • 14
0
votes
3 answers

Perform same operation on different class members without duplicate code

How do I perform the same operation on different class members without duplicating code? I have a function which creates an object of type Farm, and then performs some kind of a calculation on its members (in this case, it prints the member…
0
votes
0 answers

What is the difference between constructor parameters and member variables in Kotlin classes?

I discovered that both constructor parameters and member variables behave almost the same way. The only difference is that: the noOfSides cannot be changed inside class Square, whereas noOfSideVar can be changed inside the class Square Code that I…
user16537655
0
votes
1 answer

Class operators can not access member variables

I am working on an integer class that should be able to do basic arithmetic. The integer values are stored in an array where every array element holds two integer values. I convert this array of integers into the member variable integer. class…
Alex
  • 7
  • 2
0
votes
1 answer

Accessing member in nested composition in C++

If I have a class that contains another class (through composition) which in turn, contains another class. For example: a Teacher class containing a PersonalDetails class, that contains a ContactInformation class. ContactInformation class: class…
Henrik
  • 69
  • 1
  • 2
  • 4
0
votes
2 answers

Declaring and changing class instances inside another class

Hello fine people of Stackoverflow! I have a problem. I am trying to change an instance variable (which is on it's own a class instance) and for some reason, it changes the same instance variable for all instances of the original class. here is the…
0
votes
2 answers

assign None values to all arguments of an arbitrary class'

I want to make a method whose arguments are an arbitrary class and a list of instances. let's say the name of the class is 'Price' and the name of the list is 'price_list' def CreateHTML(_class, _list): one_instance = _class …
0
votes
3 answers

Where is the recommended way to put member variables when designing classes in python?

I am trying to get familiar with classes in python. In C++ the structure of a class seems straightforward to me, regarding the member variables. You just declare them at the beginning of the class scope or at the end (as public or private, as…
Aufwind
  • 25,310
  • 38
  • 109
  • 154