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]
159 questions
0
votes
2 answers
Should you use member variables or property getter/setter?
Possible Duplicate:
What is the difference between a field and a property in C#?
I routinely have a need to create protected variables in my class/subclass hierarchies. However I keep seeing others implementations which use a simple get/set…
![](../../users/profiles/168179.webp)
Mark A. Donohoe
- 23,825
- 17
- 116
- 235
0
votes
1 answer
Member variables being re-initialised after MessageBox?
I have a Form which has code similar to this:
public partial class Form1 : Form
{
private int m_var1;
private int m_var2;
string sMsg;
bool bReturn;
private bool MyFunction()
{
// POINT A: at this point m_var1 and…
![](../../users/profiles/327528.webp)
CJ7
- 20,640
- 59
- 173
- 305
0
votes
1 answer
Web user control member variable not accessible when not declared static
I am creating a web user control using C# to play some .wav files in the server. Following is my code.
public partial class WaveFilePlayer : System.Web.UI.UserControl
{
//private string[] files;
private static string[] files;
protected…
![](../../users/profiles/1537404.webp)
manas
- 400
- 6
- 24
0
votes
1 answer
Mapping of the members variables to iterate
In my C++ / QT application I've got a struct with hundreds of variables organized like below:
struct MyStruct
{
int a1;
double a2;
struct InnerStruct
{
int b1;
bool b2;
struct InnerInnerStruct
{
…
![](../../users/profiles/292039.webp)
sithereal
- 1,636
- 9
- 15
0
votes
1 answer
defining member variables inside an array operation
I was wondering if it is bad convention to declare my member variables inside an array that I later use somewhere else (in the code below, I pass into the insertArray() function). Here my code:
class myClass{
private $ID;
private $name;
…
![](../../users/profiles/1417660.webp)
rafiki_rafi
- 1,045
- 1
- 8
- 26
0
votes
1 answer
Is @fname similar to invoking this->fname in other languages
Let's use this class definition as an example:
class Person
def fname
@fname
end
def fname=(fname)
@fname = fname
end
def lname
@lname
end
def lname=(lname)
@lname = lname
end
end
Just trying to connect the dots…
![](../../users/profiles/98299.webp)
stanigator
- 10,102
- 32
- 88
- 126
0
votes
4 answers
Accessing "this" Type JavaScript Variables From Other Functions
I have an event firing and even though it's inside of the function from which I'm trying to access variables, I get Uncaught TypeError: Cannot read property '...' of undefined. So, let's say:
( function($) {
$.fn.main = function() {
…
![](../../users/profiles/949406.webp)
Gabriel Ryan Nahmias
- 2,039
- 1
- 22
- 39
-1
votes
1 answer
How does ones code access member variables in a different stack frame
class foo {
public:
foo() : foo_member1(1)
int foo_member1;
void do_something() {foo_member1++;}
}
int main(){
foo my_foo;
my_foo.do_something();
}
Where is everything stored in the above example code? It was something I…
![](../../users/profiles/5054121.webp)
Thomas Mathews
- 43
- 4
-1
votes
1 answer
Class objects member variables won't change when function is called
My problem is that I can not change the class members variable value, I tried everything that has come to my mind
So here is the following code that is involved:
if(player.getCollisionObject().isColliding(platform1))
{
…
![](../../users/profiles/9648868.webp)
muhm
- 1
- 2
-1
votes
1 answer
Why are my Class member variables going missing in Python?
I made a class. I think that I create a member variable named "myTup" in the initializer/constructor. I try to make sure that I actually did create myTup by making the following call right at the very end of the initializer:
assert(hasattr(self,…
![](../../users/profiles/6676101.webp)
Toothpick Anemone
- 2,131
- 10
- 25
-1
votes
1 answer
Can't assign an member variable address to a pointer
Layer::Layer(int LayerSize, Layer PrevLayer){
Size=LayerSize;
Column=(Neuron*)malloc(Size);
for(int i=0;i
-1
votes
1 answer
#define conflict with variable in .dll header file
I am using Unreal Engine 4 with some external .dll libraries. I have encountered a problem where "PI" is defined in unreal engine core code as "3.141592..." like this:
#define PI (3.1415926535897932f)
However, in the header file…
![](../../users/profiles/6812136.webp)
MrCravon
- 53
- 4
-1
votes
1 answer
How do I assign a member variable from command-line argument in C++?
Is there a way to assign a class member from a command line argument so that ALL objects of that class have that value (by default)? I want it by default because a member function creates a new object in the Foo class, and I don't want to make Var a…
![](../../users/profiles/4262074.webp)
asrjarratt
- 185
- 3
- 14
-1
votes
1 answer
What are the importance of prefixes in member Variables?
Okay, so I am going through the Android development tutorial book: The Big Nerd ranch and I am on chapter two where it tells you that you need to have certain prefixes and not have certain prefixes before getters and setters.
"What is the point of…
![](../../users/profiles/2300049.webp)
entropy
- 143
- 1
- 3
- 10
-1
votes
2 answers
Segmentation fault when a member variable of type std::map is not declared in all compilation units
When I declare a member variable of type std::map in one compilation unit but not the other, I get a segmentation fault when the containing object is being destructed. When I do the same with std::vector, it works just fine.
It was definitely a bug…
![](../../users/profiles/368405.webp)
fhd
- 3,928
- 2
- 19
- 18