Questions tagged [non-static]

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).

525 questions
7
votes
1 answer

boost::signals2 slot as a non-static function member?

I have been playing around with boost::signals2 for learning purposes lately, and I was wondering whether I could connect signals to a non-static slot located within a class (like I could in Qt). Consider the following: class Worker { typedef…
nikolas
  • 8,707
  • 9
  • 50
  • 70
6
votes
1 answer

What are the non-syntactic differences between static and non-static inner classes in Java?

Possible Duplicate: Java inner class and static nested class An instance of a static inner class cannot access the instance members of its enclosing class, whereas an instance of a non-static inner class can. This is what i mean by syntactic…
weidi
  • 852
  • 7
  • 20
5
votes
3 answers

PHP: Design pattern for classes offering static and non-static methods

My objective is to create class that can be used both static and non-static way. Both ways have to use the same methods, but in different way Non-static way: $color = new Color("#fff"); $darkenColor = $color->darken(0.1); Static way: $darkenColor =…
Adam Pietrasiak
  • 12,773
  • 9
  • 78
  • 91
5
votes
4 answers

How can a non-static class call another non-static class's method?

I have 2 classes both non-static. I need to access a method on one class to return an object for processing. But since both classes is non-static, I cant just call the method in a static manner. Neither can I call the method in a non-static way…
DarkDestry
  • 183
  • 1
  • 11
5
votes
4 answers

Is there any way for a static method to access all of the non-static instances of a class?

This is probably a dumb question but I'm going to ask it anyways... I am programing in C#.NET. I have a class that contains a non-static, instance EventHandler. Is it possible to trigger that EventHandler for every instance of the class that exists…
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136
5
votes
3 answers

Accessing class member from static method

I know there are a lot of threads talking about this but so far I haven't found one that helps my situation directly. I have members of the class that I need to access from both static and non-static methods. But if the members are non-static, I…
Jeremy
  • 147
  • 1
  • 1
  • 14
4
votes
1 answer

How to make a proper call from Android to a non-static function in Java? (Cocos2Dx in the mix)

So I'm developing a small project with Cocos2Dx but I'm trying to add Bluetooth functionality, and that implies calling a non-static method to be able to access the Main Activity's association to the Android API. Almost everything that I've seen…
4
votes
1 answer

How do I make Python respect iterable fields when multiprocessing?

Apologies if this is a dumb question, but I've not found an elegant workaround for this issue yet. Basically, when using the concurent.futures module, non-static methods of classes look like they should work fine, I didn't see anything in the docs…
4
votes
1 answer

In java, How System.out.println method works in both static and non static context?

How System.out.println method works in both static and non static context? Is there any JVM specific implementation is the answer for this?
bpn
  • 47
  • 3
4
votes
2 answers

Using a non static variable on a static method through an object? Java

Since we can't use this inside a static method, and we also cannot use non-static variables, why is it that we can use objects, which use nonstatic variables inside static methods? Here is what I mean: public int x; public int y; public Account(int…
Tom
  • 279
  • 1
  • 11
4
votes
2 answers

Instance vs. static method. Calling it statically or dynamically

In PHP there is instance methods and static methods (just these two types)? Then we can call either of these statically or non-statically (is the name "dynamically"?)? So we can: Call an instance method statically; Call an instance method…
user9098366
4
votes
3 answers

Internal working of static and non-static forward references in Java

I am working with forward references in Java and wondering why Java allows forward reference with either ClassName (in static variable) or with this reference in case of instance variable? What is the background process that is taking place at the…
patrick.1729
  • 4,222
  • 2
  • 20
  • 29
4
votes
2 answers

java: non-static variable this cannot be referenced from a static context

I have error java: non-static variable this cannot be referenced from a static context when compiling the code in line Man m1 = new Man("a1", "b1", 11); How to fix that? public class Solution { public static void main(String[] args) { …
genek
  • 113
  • 1
  • 4
4
votes
1 answer

C# should Singleton contain static methods?

I am having a lot of trouble choosing between using Singleton or Static for a class that contains state variables. I wanted the class object to instantiate and exist only as one. I know both ways can store state variables. Static Class seems easy to…
Kei
  • 121
  • 1
  • 10
4
votes
0 answers

Static ThreadPool vs Singleton ThreadPool

In the following class i'm using a SingleThreadPool (which is static) and i've made sure the static thread pool is initialized only once by using a Boolean object and making it synchronized(see init() method).I've made ThreadPoolExecutor static…
Raghu
  • 1,363
  • 1
  • 23
  • 37
1 2
3
34 35