Questions tagged [static-methods]

Methods that neither require an instance of the class nor can they implicitly access the data (or this, self, Me, etc.) of such an instance.

Static methods neither require an instance of the class nor can they implicitly access the data (or this, self, Me, etc.) of such an instance. A static method is distinguished in some programming languages with the static keyword placed somewhere in the method's signature. Static methods are called "static" because they are resolved statically (i.e. at compile time) based on the class they are called on; and not dynamically, as in the case with instance methods which are resolved polymorphically based on the runtime type of the object. Therefore, static methods cannot be overridden.

Source: "Method (computer programming)" article on Wikipedia

2793 questions
1
vote
1 answer

Calling a superclass method from a subclass in python

I was wondering if a subclass could call its parent static method, and tested it : it works like I hoped! class A(object): @classmethod def static(cls): print('act on '+cls.__name__) class B(A): def foo(self): …
Ailete619
  • 194
  • 1
  • 18
1
vote
0 answers

Can we use static functions in multithreading environment?

I'm new to Java and Selenium. In selenium test I want to check whether element is displayed before performing any action on it. I have written static function to check for element existence. I'll be running tests in parallel, this function will be…
1
vote
1 answer

Why do I get an "Unresolved Externals" when calling a static attribute? Visual C++

although there are a lot of answers to this topic, I still have a problem. I want, like everybody, to implement a Singleton pattern. I tried with this: class Factory { private: Factory(void); static Factory* self_inst; public: …
1
vote
2 answers

Trouble with static and non-static

I'm new at Java and following a beginners course right now. Very nice, i'm trying all kinds of stuff but now i'm stuck. This piece of code doesn't work. It should output the input in reverse order (by words). The code to flip it works in a piece of…
1
vote
4 answers

Call static function in C++

I am writing a code to work with vectors in C++. I've got 3 files: main.cpp, Vektor.cpp and Vektor.h Now I want to call a static funktion in main, which is implemented in Vektor.cpp and declarated in Vektor.h. "test" and "test2" are two instances of…
N8_Coder
  • 713
  • 3
  • 10
  • 20
1
vote
0 answers

How to register a client side script in a static web method?

I want to register a client side script in a static web method. Here is my codes: public static class ScriptRegister { public static void RegisterScript(Page page, string script) { …
cagin
  • 5,772
  • 14
  • 74
  • 130
1
vote
1 answer

Behavior of static methods/variables change after adding instance variable in Java

This isn't so much of a problem as it is a question. I have several classes that inherit the following abstract class: public abstract class PixelEditorWindow { protected static int windowHeight, windowWidth; public PixelEditorWindow() { …
1
vote
1 answer

Static richbox in C#

How can I make a richtextbox static in a form ( C#) in order to call it in other class and define a static method who can change it?
Gee_Djo
  • 243
  • 1
  • 2
  • 4
1
vote
3 answers

Alternative to virtual static functions in c++?

In the header file .hpp: class Base{ public: static /*Some Return Type*/ func(/*Some Datatype*/); } class Derived1 public Base{ public: Derived1(); ~Derived1(); } class…
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
1
vote
1 answer

Deallocate and re-instantiate new a singleton

I want to de-allocate the memory from the original singleton object and create a new one with another method. public sealed class ObjectZ { static readonly ObjectZ _instance = new ObjectZ(); private ObjectZ() {} public static ObjectZ…
Glimpse
  • 462
  • 2
  • 8
  • 25
1
vote
1 answer

Issue with static encryption/decryption in a multi-threaded/TPL application

I have a static encryption/decryption class with static methods in one of my libraries. The code is a bit large so I posted it here: http://pastebin.com/zRZtNmjU I haven't had any issues with this code until it started being used within the…
1
vote
2 answers

Declaring a non-static class as static

I have a static class called A: public static class A { } And another class called B, which is not static: public class B { } After that, I declared the non-static class B as static: public class c { // declare a non static class (B) as…
User2012384
  • 4,769
  • 16
  • 70
  • 106
1
vote
2 answers

Difference of static const and static when returning a static variable

It is best explained in code: static Unit& None() { static Unit none(....); return none;} What is the difference to? static const Unit& None() { static Unit none(....); return none;}
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
1
vote
2 answers

Action Script 3 Static Method

I'm new to Action-script OOP and i need to know how to chain methods like this example i have I.$(button).bind('click',clickButton).bind('rollover',overButton).bind('rollout',outButton) First i need to remove the I. to use dollar sign only like…
Ahmed Saber
  • 489
  • 1
  • 9
  • 21
1
vote
3 answers

How To Convert Templated Function Overloads to Partial-Specialized Templated Class Static Methods?

I have several functions that I want to specialize based on type qualities, such as "character, signed-integer, unsigned-integer, floating-point, pointer"; using type_traits seems like the way to do this, and have code similar to the to the…
1 2 3
99
100