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.)
Questions tagged [member-variables]
169 questions
0
votes
1 answer
How to pick up values from MainActivity in another class
I assume it would be a good idea to put long-winded functions in a class other than MainActivity. However, I'm having difficulty using values from MainActivity in a separate class.
To test this I have MainActivity as
package…

prepbgg
- 3,564
- 10
- 39
- 51
0
votes
1 answer
C++ Private Memeber Variable Inaccessible to Memeber Function
I am working on recreating pong, and while moving drawPaddle function from the main Game class to the Paddle class I ran into an issue where the function cannot read the member variables (even though they are in the same class). The class is in a…

glonk
- 1
0
votes
1 answer
Memeber variable as class variable in C++ how does it happen?
I have a problem. I am currently working on a small example in c++ and can't figure out the explanation. Here is my problem:
#include
using namespace std;
class X{
int& i ; /* int i; */
public :
X(int k=100):i(k){ }
X(`const` X&…

Enamya
- 37
- 1
- 8
0
votes
1 answer
calling version of is_const<> but for variables instead of types, in one line
Hi I am learning c++ and I read about type traits such as is_const.
is_const can be called in one line like,
cout << is_const::value << endl;
I made my own version of is_const but to test if a variable is const, and it can be used like…

betafractal
- 6,524
- 1
- 11
- 12
0
votes
0 answers
Changing a list which is a member variable
I am relatively new to Python, and I find the following difference between numbers and lists in classes confusing. See the code below.
The class MyClass has a number some_number and a list some_list. When creating the instance myObject = MyClass()…

Jasoba
- 101
- 1
0
votes
1 answer
Member variable losing value c++ when going out of scope of BeginPlay function Unreal Engine
Unreal Engine 4.23.0
C++
When running the function BeginPlay(), my member variable _initialTransforms nicely fills in everything as expected, but the moment I'm going out of the scope of the BeginPlay() function and into the DrawRobot(...,...)…

Kevin Saey
- 1
- 1
0
votes
1 answer
Java - When member variable is set, how to set other members
I have the following legacy code as shown below. I'm wondering is there a way to set BikeName and BikeModel when BikeGroup is being set? Basically, as the user is setting BikeGroup, how can we automatically set Foo's version of BikeName and…

hyperstack
- 29
- 1
- 4
0
votes
1 answer
Is there any convinient way to check the values of the member variables of a class in Eclipse?
I am writing some code that makes use of the std::vector class to store objects of a user-defined class. For debugging, I need to keep watch on a few particular member variables of this class. Towards this end, I went to the variables view in my…

anon12c
- 11
- 3
0
votes
1 answer
Keeping member variables into smart pointers and importance of explicitly defined destructor
I have a code that was written using old style c++, such as raw pointers like is shown below(code 1):
class Thing {
private:
int data;
Thing* one;
Thing* second;
Thing* previous;
public:
…

std_name
- 3
- 2
0
votes
1 answer
Member variables of pointer changing for some reason?
I am running a thread for a scheduler and am inserting processes into the queue of the scheduler in the main thread while the scheduler thread is still running. For whatever reason the variables of the process object are changing when the object…

M. Rosenlof
- 112
- 8
0
votes
3 answers
How come we can return references to member variables of a class
I want to understand why is it possible to return a reference to a class member variable in C++, such as in the following example:
class Foo
{
int x;
public:
int& get_pvar()
{
return x;
}};
Apparently we can access the variable x in main(), create…

HeWhoMustBeNamed
- 117
- 4
0
votes
1 answer
What is performance difference between different class or struct initialization methods?
We have different types of initializing class or struct member variable at c++
one of them is:
struct foo {
foo() : a(true), b(true), c(true) {}
bool a;
bool b;
bool c;
} bar;
and another one is :
struct foo {
bool a = true;
…

clever tiger
- 33
- 4
0
votes
3 answers
get associated getter/setter of field (member variable)
I have a Field f of some class MyClass and I want to retrieve the associated getter/setter, if it exists. How do I do this?
I checked the methods of Field, but there is not even one that returns a Method.
I played around with BeanInfo retrieved by…

Kjara
- 2,504
- 15
- 42
0
votes
0 answers
C++ Member variable Initialized with non-zero value, but is zero in member function
New to c++, I'm trying to make a simple start screen for a video game. I want the start screen to scroll in from the bottom of the screen. In order to do this, I have some member variables that are accessed in a function called Update. The problem I…

bitwitch
- 467
- 1
- 5
- 15
0
votes
2 answers
Getting Netbeans autocomplete working for a JavaScript project with lots of classes as includes
I have a project in Netbeans 8.0 with around 12 javascript includes. When in one JavaScript class file, if I instantiate another custom class from the project and press "." after the var name, it does not pop up any autocompletes with my member…

OG Sean
- 971
- 8
- 18