79,869 questions
66
votes
7
answers
96k
views
How to initialize static members in the header [duplicate]
Given is a class with a static member.
class BaseClass
{
public:
static std::string bstring;
};
String has obviously to be default-initialized outside of the class.
std::string BaseClass::...
2
votes
4
answers
6k
views
PHP extending class properties
I have two classes in a PHP application, B extending A for example.
Class A has a function which returns some of its other properties in the form of an array of SQL insert queries eg
Class A {
$...
-2
votes
3
answers
3k
views
Creating turtles with OOP in Python with turtle graphics
I want to take this
t=turtle.Turtle()
t.color("white")
t.pensize(2)
t.shape("turtle")
t.speed(0)
And make many of them with OOP
, so I tried and it didn't work
class turtles:
def __init__(self, ...
-1
votes
3
answers
225
views
Python self.page.snack_bar doesn't work in Flet
I'm a beginner student and trying to validate my login code showing a snackbar mensage. There are no erros to run, but snackbar doesn't appear.
At first a tried if a firebase authentication, and i ...
0
votes
3
answers
12k
views
PHP | Access to undeclared static property
After trying several attempts at this for some reason i get the error Access to undeclared static property when i try to make an object out my class.
My class:
final class repo {
var $b;
/**...
1
vote
1
answer
171
views
ESP32-S3. Arduino Framework: SD card reading problems when implemented using classes
This is my first post here. I'm having the following problem. I have some code that transfers a gif file from SD card to flash memory and then uses a TFT display to show it.
The following code works ...
2
votes
3
answers
506
views
Member function a friend
I've been trying some examples in a book (C++ Primer by Stanley Lippman)
and I understand that a class can make another class its friend (to access some private members). Now I'm reading about a ...
98
votes
4
answers
68k
views
Styling elements with a dot (.) in the class name
Hay I have an element like this
<span class='a.b'>
Unfortunately this class name comes from an eCommerce application and cannot be changed.
Can I style a class name with a dot in it?
like
.a....
70
votes
10
answers
69k
views
What are sealed classes in Java 17?
Today, I updated my Java version from 16 to 17, and I found that sealed classes is a new feature in it. I think it can be declared like this:
public sealed class Main permits AClass, AnotherClass {
}
...
1
vote
3
answers
1k
views
why is react-player playing video even when playing={false}?
The react-player is playing video even when playing={false}. I'm using antd modal which is wrapped around my player.
when I close the modal state changes to false. Which is passed in react-player but ...
0
votes
1
answer
90
views
Can I directly assign a new object reference variable to the original current object, inside the object class?
Lets say I am trying to reverse a SinglyLinkedList object list. I would do so like this:
public void reverseList() {
SinglyLinkedList<E> reverse = new SinglyLinkedList<>();
Node<...
221
votes
11
answers
226k
views
How to initialize static variables with a function call?
I have this code:
private static $dates = [
'start' => mktime( 0, 0, 0, 7, 30, 2009), // Start date
'end' => mktime( 0, 0, 0, 8, 2, 2009), // End date
];
I get the following ...
14
votes
6
answers
34k
views
Get all instances of class in Javascript
I thought there would already be an answer for this but I can't seem to find one..
How can I run a particular class method on all instances of this class in Javascript?
This has to be done in a ...
2
votes
1
answer
145
views
Unsure how to create relationships between classes within python
The classes works when separate, now, I want to create relationships between them. However, this has caused issues when I am trying to define the relationships.
For example:
sqlalchemy.exc....
0
votes
2
answers
126
views
Create a custom method for all existing product types in WooCommerce
I want to create a custom method I can use for any WC_Product class, so I can use $product->get_lead_time(); anytime I have a product object available. I currently have it working for Simple ...
11
votes
6
answers
22k
views
Using jQuery to Add a Class Attribute to images, etc. on Page?
Li'l Help? Apologies in advance due to my jQuery.noob status, but I'm drawing a blank and about out of ideas on why this isn't working. Maybe someone here can see something I'm not? I'd surely ...
0
votes
0
answers
39
views
Base class undefined. How would I go about fixing this issue?
I want to create the object "keyEventsInstance" on the stack as a private member of the class "MultiLauncher" (see MultiLauncher.h) and then have keyEvents::processKey(uint key) ...
36
votes
2
answers
64k
views
How to pass a C# struct by reference?
In my C# application I receive a pointer to a C++ struct in callback/delegate. I'm not sure if class can do the trick, but just casting a C++ pointer to an appropriate C# struct works fine, so I'm ...
3
votes
1
answer
3k
views
Passing structs or classes to CUDA kernels - is it safe? advisable?
I'm relatively new to CUDA programming, so I want to clarify the behaviour of a struct when I pass it into a kernel. I've defined the following struct to somewhat imitate the behavior of a 3D array ...
117
votes
17
answers
95k
views
Does C++11 have C#-style properties?
In C#, there is a nice syntax sugar for fields with getter and setter. Moreover, I like the auto-implemented properties which allow me to write
public Foo foo { get; private set; }
In C++ I have to ...
0
votes
1
answer
64
views
How to seperate string by commas and colons using linq?
I have a incoming string in the following format: "LARGE:34,MEDIUM:25,SMALL:15"
I have the following class :
public class Portion_Price
{
[DataMember]
public PortionSize PortionSize { get; ...
0
votes
1
answer
9k
views
java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory error
I am trying to connect my client application to JBoss 7.1.1. MHSessionBeanRemote is my server side bean class.
Code of my class
import java.util.Properties;
import javax.naming.Context;
import javax....
1
vote
2
answers
1k
views
Why create a class with no constructor and filled with static methods in JavaScript? [closed]
I am reading a project with legacy code and I found something like this (simplified here):
class FooUpdater {
static getData() {}
static someFunc() {}
static otherFunc() ...
3
votes
4
answers
94
views
Why must classes be defined in order of appearance in python module?
Let's say I have a python file test.py that looks like this:
class MyFirstClass():
prop=3
class MySecondClass():
prop1 = 0.
prop2 = MyFirstClass()
Then I can run this and it works:
from ...
1
vote
1
answer
65
views
D365 FO X++ SRS report field value is repeating every line using the first line
This is using D365 Finance and Operation, I have a field in SRRS report table suing X++ language to code, one field value looping every line with the same value using the first line of value. I want ...