Skip to main content

Questions tagged [static]

Static is a term used in some programming languages to define a function or data storage area (field) that is not bound to any specific object instance. In the majority of cases this tag, if used, should be used in conjunction with a specific programming language tag.

0 votes
0 answers
28 views

What happens when I have 2 static variables with the same name? [duplicate]

I am a Java beginner and am having trouble understanding the output of the System.out.println(((A)b).s) in the code. My understanding is that static variables can be changed anywhere in the class and ...
Amadeus's user avatar
  • 11
1 vote
1 answer
47 views

Objective benefit of static local function that's only called once?

Recently I was looking at the source code of Stream.CopyToAsync, which is available here on github. The author first validates the parameters and then calls a static local function that does the ...
Lukas-T's user avatar
  • 11.3k
0 votes
1 answer
32 views

CRTP static variable not initialized without constructor [duplicate]

I was trying to write a factory that types could register to using CRTP, like this question, and I was having some issues. #include <iostream> #include <map> #include <functional> ...
BadProgrammer99's user avatar
0 votes
0 answers
22 views

Angular SSR generates browser and server folders on build. Can I use the site as static or with server-side rendering after configuration?

After setting up and running with SSR, Angular initially renders on the server.I'm on angular version 18.1.0 After the initial load, Angular takes over and the application operates as a Single Page ...
Fábio Brasileiro's user avatar
-3 votes
2 answers
64 views

Static variables in Visual Studio 2022 throws error [closed]

I am trying to declare a static variable in VS 2022 in a console app. TreeNode prev = null; static TreeNode treeToDoublyList(TreeNode root) { TreeNode dummy = new TreeNode(0, null, null); prev ...
user1094183's user avatar
0 votes
1 answer
36 views

PHP: Lazy-evaluated static variable

I have a function that is called many times that look like this: function attachImagesToProduct(Product $csProduct) { $searchPath = realpath(__DIR__ . "/../images"); $files = scandir(...
user26333271's user avatar
-1 votes
0 answers
47 views

Can I generate a static variable with code? [duplicate]

I have a class that has a static dictionary that maps ids to names class Foo { static idToName = { 2: "John", 8: "Peter" } } Now, I also need to be able to get the id ...
Elerium115's user avatar
-2 votes
0 answers
13 views

Why constructor cannot access static variable inside the constructor block?

Why static variable can't be accessed using this keyword inside a constructor I created a static variable and a no argument constructor inside a class when I try access the static variable with the ...
Yogi's user avatar
  • 1
0 votes
1 answer
50 views

How to use `static` with an array of array in C

Given, int last(int arr[3][6]) { return arr[2][5]; } I want to make it clear that arr can't be null with the static keyword. The problem is that the following code won't work. int last(int arr[...
gberth's user avatar
  • 670
0 votes
1 answer
55 views

Why I didnot get Multiple definition Error?

#include <stdio.h> #define MAX 5 static int data = 10; int increment(void *); int increment(void *ptr) { int *p = ptr; static int data =15; for (int loop=0; loop < MAX; loop++...
fw08's user avatar
  • 126
-1 votes
0 answers
39 views

How to make a C++ struct that can have multiple independent static variables for each object of the struct? [duplicate]

I'm currently working on a Predator/Prey simulation in C++, and I'd like to keep track of certain stats (number born, number alive, and number died, specifically) for each one of various types (Animal,...
GorgeGrouse's user avatar
0 votes
0 answers
40 views

Accessing public assets via server action nextjs

I'm working on a Next.js 14 application where I need to use images stored in the public folder. While the images load correctly on the client side, I encounter issues when trying to read an image file ...
Zuhlek's user avatar
  • 3
2 votes
1 answer
135 views

How to access a static property Swift 6 concurrency-safe?

My app uses a class A and its subclasses SubA_x. A has a static property serialNumber that is only modified by class A when a subclass is initialized. It sets a property let name so that every ...
Reinhard Männer's user avatar
0 votes
0 answers
49 views

Why /static/ not showing up for /admin in Django project?

So, I've been trying a bunch of things. Settings look good to me but maybe I am missing something. I use: PostegreySQL, Reddis, Celery beat, nginx, gunicorn. I can't figure out what the problem is: ...
Zebra Turner's user avatar
0 votes
2 answers
68 views

Static variable and type: could there be another simpler way to implement a function that returns the same ID for each user-defined type?

I was working on creating an entity-component system on my own, and in doing this I have gotten help from a lot of YouTube videos, C++ references, recommended books, etc. While I was implementing a ...
Luffy_one's user avatar

15 30 50 per page
1
2 3 4 5
1098