Category "class"

Is it legal to have 2 header files for the same class in c++?

In a project I read, there are two header files and two declarations for the same class. One is used by programs that use this library, serving as an interface.

Best practices for declaring class constants with PHP?

When I design classes in PHP and I need (or want) a constant I usually declare it as a class constant like this: class MyClass { const FOO = 1; } Then I ca

How do I call a method for all objects in a class?

I want to call a method for all objects in a class at once. What's the simplest way to do that? Also, how do I call a method for some, but not all objects in a

Outer class can't create an object of my inner class [duplicate]

I am so confused. I have a nested class where Book is the inner and Bookshelf is the outer class. When I try to create a Book object in my Boo

Take a class as a parameter which has a particular method in it

I know that we can pass a class in a param which has a particular class as its super. For example, see this: public void sampleMethod(Class<? super MyParentC

Base Class extended Incorrectly

Hey I am using Deno and extending EventTarget class but I don't want the end user to be able to get functions which exist on EventTarget class like addEventList

Property initializers run before 'self' is available

Seems like I'm having a problem with something that shouldn't be the case... But I would like to ask for some help. There are some explanations here on the Stac

How to assign a database model to a user

from django.db import models from datetime import datetime from django.contrib.auth.models import User class News(models.Model): user

Why is my linked list size function not working as intended?

I used the following code to define my linked list, nodes and a few functions. class node: def __init__(self,node_data): self.__data=node_data

Custom utility types (generic types) for classes `IsClass` of TypeScript

I am trying to create a generic type to make sure the first parameter to be a class. However, the factory function parameter cannot be replaced by a generic typ

Are there any Java Class Library "header files" containing all method descriptors in the standard library?

In order to create a valid .class file, every method has to have a full internal name and type descriptors associated with it. When procedurally creating these,

i am using a small php microframework and keep getting an error Uncaught Error: Undefined constant "mu"

Fatal error: Uncaught Error: Undefined constant "mu" in E:\xampp\htdocs[[myphpframework]]\mu-clean\examples\hello1.php:3 Stack trace: #0 {main} thrown in E:\xam

Using different instance of self as argument to method in python

I'm trying to create a method that takes self and another instance of the same method as its arguments, for example: class AClass(): def __init__(self

/Main.java:17: error: non-static variable this cannot be referenced from a static context ^ 1 error [duplicate]

In this simple code can anyone explain me what's wrong ? public class Main { public class UserValidator { public void validateName(String

VBA: Creating a class property that is an array of dictionaries

In Microsoft Excel VBA I need to create a class that has two properties, "Name" and "Holdings". "Name" is just a string so the code for that is easy. But I ne

python workaround gpiozero when_motion with multiple sensors

i'm trying to listen on 3 motion sensors, each one triggering its own sound i'm using when_motion because it's creating a thread, so i can do other thing while

How do I make this function more efficient?

I'm trying to create a tiny database that contains a list of people, their names, ID, and their income as time passed on. Using this database I'd like to find t

Pythonic way to control an attribute over another attribute

There is a pythonic way to control attributes? I wan't that the init method is clear, trying to avoid to use a function like: self.a = check_a_greater_than_b(a)

VBA UserForm Frame ScrollTop function not working from class function

This should be a simple task and I've been coding in VBA for 10+ years but I cannot seem to get this to work. I have a UserForm with a MultiPage (with 2 pages)

Still can't use a function defined in a separate .cpp file

I've been searching through questions on this for hours, and it just isn't working for some reason, so sorry if there's already an answer and I just didn't unde