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
2
votes
2 answers

Calling a method from an array-list of objects

I'm just starting with Java and I'm having trouble with the following code. I was using something like this to call the non-static apply method from a static method, but I dont think its very efficient. I set an array list of the rules that need to…
tom3322
  • 133
  • 2
  • 2
  • 8
2
votes
1 answer

Accessing non-static member variables from static methods

I'm just starting on Java and I need some help. I know I cannot make a non-static reference on a static method but I need help trying to work around it. I was reading you can access non-static member variables, by creating an instance of the object…
tom3322
  • 133
  • 2
  • 2
  • 8
1
vote
1 answer

Call a non-static variable so it can be used by another class (cannot instantiate)

I have a problem I have some classes of objects, they are called "cat" "dog" etc.. Within these classes I have assigned each cat and dog object their own integer energy level (so when they "move" through a 2dimensional array they loose and gain…
ssjg0ten5
  • 11
  • 2
1
vote
1 answer

C++: member call to non-static member function pointer

Possible Duplicate: C++ member-function pointer How to invoke pointer to member function when it's a class data member? I've only recently started using C++, so I apologize if the following contains any trivial mistakes, or if I missed an easier…
f4_
  • 23
  • 4
1
vote
2 answers

Asp.net C# Static Method Thread Safe Error Handling

Sometimes its the simple things you thought you knew that make your head buzzz.... I have an Asp.Net (forms) application that uses the static methods of a non-static class to do some processing on PostBack. Those methods need to return bool. When…
Serexx
  • 1,232
  • 1
  • 15
  • 32
1
vote
1 answer

C++ undefined class declarations which I have already included

My problem is about including header files. I don't want to include headers in other header file so when I need it, I always write declarations the beginning of the header and include in the cpp files as you can see, but this time it does not…
yigitEmre
  • 31
  • 5
1
vote
1 answer

Using ref in (whole) partial class

I got some confusion about "the right way" to use a reference in a partial class. Basically i wrote a WPF program which has different Menus. Every Menu got the same Viewmodel and some data-related object class. In my case i call the Object…
Knally
  • 31
  • 3
1
vote
1 answer

c# how access a non-static public variable from action

I'm using a NuGet package, FFMpegCore, to transcode videos in a Windows Service created with VS 2022. The package calls an Action during the transcoding process that gives status information which I'd like to return to the user using their org and…
Velocedge
  • 1,222
  • 1
  • 11
  • 35
1
vote
1 answer

Java : call a non-static field of an abstract class in conflict with an interface's field

How to display the value of the "name" non-static field from the abstract class Confused("ConfusedValue") ? I tried 3 ways, but all have errors. I can display only the Confuslable's name value("ConfusableValue") interface Confusable { String…
SOUE77
  • 39
  • 6
1
vote
1 answer

How to call loadview Non Statically in laravel?

$pdf = PDF::loadView('pdf_view', $data)->setPaper('a4', 'portrait'); Non static method 'loadView' should not be called statically.intelephense(1036)
Rakesh L
  • 49
  • 1
  • 4
1
vote
1 answer

Android Data Binding Error : non-static variable R cannot be referenced from a static context

I got the following error while building my android project in the Layout Data Binding auto generated class error: non-static variable R cannot be referenced from a static context View root = inflater.inflate(R.layout.rgb_input_layout, parent,…
1
vote
1 answer

can derived class access base class non-static members without object of the base class

can derived class access base class non-static members without object of the base class class base { public: int data; void f1() { } }; class derived : base { public : void f() { base::data = 44; // is this…
1
vote
1 answer

Is a declaration for a non-static data member of a class type also a definition?

I am learning C++. In particular, the difference between declaration and definition. To my current understanding All definitions are declarations but not all declarations are definitions. Here is an example of what I currently know. int x;…
Jason
  • 36,170
  • 5
  • 26
  • 60
1
vote
3 answers

Why C++ static data members are needed to define but non-static data members do not?

I am trying to understand the difference between the declaration & definition of static and non-static data members. Apology, if I am fundamentally miss understood concepts. Your explanations are highly appreciated. Code Trying to understand class…
Sadeesh Kalhara
  • 129
  • 1
  • 7
1
vote
2 answers

Reference to non-static Member Function

https://leetcode.com/problems/sort-array-by-increasing-frequency/ In this leetcode question, I wrote the following code: class Solution { public: bool compare(pairp1,pairp2) { if(p1.second
Vatsal A Mehta
  • 392
  • 2
  • 15