non-static is a term to define a function or field that is bound to some object instance. Without an instance, non static fields cannot be accessed and non static methods cannot be invoked. Unlike static, non-static methods can be overridden (virtual).
Questions tagged [non-static]
525 questions
4
votes
6 answers
Android Studio static or non-static variables and methods
I'm a little confused about when a variable or a method should be static. I've developed an app with several classes, variables and methods, and very rarely use the keyword static. Yet it works satisfactorily. Could you tell me if I make mistakes…

Andy
- 99
- 1
- 2
- 9
4
votes
3 answers
How does java handle non-static variables?
I am having problems understanding the way non-static variables are handled. I chose to work with an array so that it is easy to retrieve its memory address.
Consider the following code:
public class tryClass
{
int[] v = {0}; // vector v is…

AndreasT
- 207
- 2
- 8
4
votes
1 answer
How to send broadcast in a broadcastreceiver Android
I have written a inner class BroadcastReceiver in a Service. And I want to send another broadcast in onReceive() of BroadcastReceiver to an Activity.
My code is:
public static class ServiceBroadcastReceiver extends BroadcastReceiver
{
…

sgyaqing
- 51
- 1
- 4
4
votes
1 answer
error in unused template method
struct B
{
int a;
void foo() {a = 5;}
};
template
struct A
{
A(int i) { B::foo(); }
A(double d) {}
};
int main()
{
A a(5.0);
}
gcc 4.7.2 compiles it without errors.
clang 3.4svn complains:
$ clang -Wall…

Trass3r
- 5,858
- 2
- 30
- 45
4
votes
1 answer
Powermock verify private static method call in non static method
Dear stackoverflow comrades,
I again have a problem in getting a specific PowerMock / Mockito case to work. The issue is, that I need to verify the call of a private static method, which is called from a public non-static method. A similar example I…

Malvin
- 859
- 2
- 11
- 19
4
votes
3 answers
Illegal reference to non-static member... typedef?
Why do I get
Error C2597: Illegal reference to non-static member 'derived<>::T'
when I try to compile this code in Visual C++ 2010 x64? (It seems fine on x86... which one is correct?)
struct base { typedef int T;…

user541686
- 205,094
- 128
- 528
- 886
4
votes
6 answers
Parsing date and running into a 'static reference to the non-static method' Error in java
I have a line in my main like so:
Date gameDate = DateFormat.parse(scanner.nextLine());
Essentially I want to scan in a date with util.Scanner
Which hits the error:
Cannot make a static reference to the non-static method parse(String) from the…

AncientSwordRage
- 7,086
- 19
- 90
- 173
3
votes
4 answers
C++: static member variable
Statement: "Static member variables can be ONLY changed by static methods."
Is this statement correct, or can static member variables also be changed by non-static methods?
Thanks!

dudade
- 71
- 1
- 7
3
votes
5 answers
Non-static method next() cannot be referenced from a static context
I am trying to parse out a mm/dd/yyyy formatted date into separate fields, but I get the following error when I try to compile:
non-static method next() cannot be referenced from a static context
What could be causing the error?
import…

Ian Conner
- 69
- 1
- 2
3
votes
4 answers
Register non-static C++ methods in Lua
I'm trying to make a small C++/Lua system where I would create my objects and attach behaviors to them in Lua. Right now I'm using LuaWrapper (a small header with basic C++ to Lua stuff), my problem is that as far as I can see Lua only let me…

Luke B.
- 1,258
- 1
- 17
- 28
3
votes
3 answers
Java - Non-static Enums
Say, I have some classes:
class NPC {
Attributes attributes;
Skills skills;
void doStuff() { //doStuffff }
}
class Player {
Attributes attributes;
Skills skills;
void doStuff() { //doStuffff }
}
And an Enum for these…

zeboidlund
- 9,731
- 31
- 118
- 180
3
votes
2 answers
Advantages and Disadvantages of static classes in c++
I am making a small game in my small game engine made with OpenGL and C++. I am using a static class called ResourceManager in my game which is responsible for loading and returning textures, shaders, audios, etc. It is static so I can get textures,…

NinjaGameDev
- 73
- 2
- 7
3
votes
2 answers
Non static method reference in enum constructor as parameter
I am trying to map some values to functions that should be applied to these values.
if simplify, i want do so:
import java.util.function.Supplier;
public enum SomeEnum {
CASE1 ("val1", this::doAction1),
CASE2 ("val2", this::doAction1),
…

clueqva
- 48
- 5
3
votes
2 answers
implicit object parameter and this pointer
With reference to Non-static member functions, under
const-, volatile-, and ref-qualified member functions
it is mentioned:
A non-static member function can be declared with no ref-qualifier,
with an lvalue ref-qualifier (the token & after the…

Vinod
- 925
- 8
- 9
3
votes
2 answers
Clarification with accessing non-static class member function via pointer
I am having difficulty accessing a non-static member function from a function pointer and can't quite figure out my syntax issue. When attempting to compile as seen below I receive "error: fnc_ptr not declared in this scope." and when if the code is…

20lbpizza
- 43
- 7