Questions tagged [class]

A template for creating new objects that describes the common state(s) and behavior(s). NOT TO BE CONFUSED WITH CSS CLASSES. Use [css] instead.

2
votes
0answers
38 views

What is the proper way of seeding std::mt19937 with std::chrono::high_resolution_clock inside a class?

First off, hello everyone! This is my first ever question here, so I hope I am not screwing up. I googled a lot before writing here. I am new to coding, to c++ and I am learning it on my own. ...
0
votes
0answers
23 views

Where will TypeBuilder.CreateType() stored, memory or filesystem?

Will TypeBuilder.CreateType() generate a local file or just keep it in memory? If it creates a local file, where will it be stored? I have seen files that sugests that it saves them to C:\Users[My ...
-1
votes
0answers
28 views

When to use case class and when to use normal class in Scala?

I am taking data from a source and doing some computation on it, and then I have to write that data in the table form. The table will contain around 20 columns, the value of each column I will pass ...
0
votes
1answer
28 views

Creating class for Complex Number in Python

I'm leaning oops in python and I'm creating class for complex numbers for doing basic math operations by overriding the operators + - * /. In doing so my updated result (which I'm storing in self) is ...
0
votes
0answers
24 views

Uncaught Error: Call to a member function fetch_assoc() inside class [duplicate]

PHP/MySQLi Prepare statement returns an error when executed inside a Class but returns data inside a function. Select statement returns data inside the class without prepare statement - what am I ...
0
votes
2answers
31 views

Javascript: Async Function Chaining in Class with return this

I am trying to do function chaining in a Javascript class by returning this after each method, but somehow, it does not work..: let sql = require('mssql'); let {logger} = require('../utils/logger'); ...
0
votes
2answers
18 views

Python : How to get non initialised attribute from one class to another one

I'm trying to send a variable from one class to another one. The problem is that i can't use the init constructor as my variable isn't defined at the beginning. If the user press one button, it will ...
0
votes
3answers
19 views

Creating multiple instance sharing common letter

I want to create several instances for a class. e.g. class container(): def __init__(self): pass let's assume I want to make four instances sharing "C" C1 = container() C2 = container() ...
-4
votes
0answers
33 views

I'm trying a maze with backtracking solvable in c ++. What is wrong?

I'm trying a maze with backtracking solvable using c ++. What is wrong? //laberinto.h #pragma once #include <vector> #define widths 33 #define heights 6 class Laberinto { public: Laberinto(...
0
votes
1answer
12 views

Updating TextField from different class than GUI

I'm new to programming in java and I'm looking to update the GUI from a different Class.Every time I have tried calling the method on a different class it doesn't work but If I do it in the GUI Class ...
2
votes
1answer
40 views

Link class to multiple other classes

My goal is to use a class inside another class, this would reduce the overall code and improve readability. There is one class that accesses the hardware, and other classes should make use of this ...
2
votes
1answer
22 views

writing a method containsInstanceOf(Class<? extends SuperClassName>)

I have written a class Couple I want to write a method containsInstanceOf like this in (1), but I get the error "can't resolve cls to a type" I've solved it by using (2). but I don't like it at all. ...
0
votes
1answer
34 views

how do I extend this class to redux?

I would like connect this class to redux like the rest of my components. This class is only responsible for calculating gain values and sending them to a Bluetooth device. This is how I normally ...
0
votes
1answer
25 views

Create a String Array in constructor and use it in main function

I'm new to hashing so i wanted to create a hashtable with an array of strings. It is working in the class itself, but when i try to use the array of strings outside of the class it's crashing. ...
0
votes
1answer
34 views

Keep the class but don't show it in the output of an R function

After creating a class for an object outputted by a function, is it possible to suppress the extra output (in the below case: attr(,"class") ; [1] "bob") not show in the output? To be clear, I want ...
-1
votes
0answers
38 views

Read PHP variable within class with SwiftMailer

I am working with SwiftMailer, and I need to send some variables from one site to another. I obtain these variables from $_GET; I can read them, and I can verify that they are correct. The problem ...
0
votes
0answers
10 views

Appending to a list from one method calling from another method [duplicate]

I have a class with several methods. One method creates an empty list, another method appends one item to that list and there is another which uses the first one to create a list and then the 2nd one ...
-1
votes
1answer
44 views

How to use a database connection class in my entire application

I have created a class for the MS Access database connection. It works fine on the majority of the forms within my Winforms app. However, I have a form where the user can add, edit or delete ...
0
votes
0answers
18 views

Create namespace class alias for a non-namespace class

I'm new to PHP 5.6+ trying to catch up, I want to create a compatibility layer for an application, consider the following scenario // classA.php, a non spaced class class A { // ONLY fallback const ...
-2
votes
2answers
32 views

Check if object's atribute was defined [on hold]

In this code example, how can i say : " if color was not defined "? class A: def __init__(self, name): self.name = name def atribute(self, color): self.color = color ...
-2
votes
0answers
33 views

Nfa with epsilon transitions to dfa algorithm [on hold]

I have created Non deterministic Automate with epsilon transitions.And my question is how can I convert nfa to dfa. There are some algorithms in the Internet but I'm not sure how to implement them ...
1
vote
1answer
73 views

Running threads from within classes

I'm trying to perform two operations at once, a loop in the program's main method that prints out Tick from main and another loop in a class that prints out Tick from ConnectionManager. This specific ...
-2
votes
0answers
17 views

Recommendation about class/dictionary for agents simulations

I would like to implement my own simulation involving several hundreds agents, where each one is characterized by its geographical position, status, destination etc. These features would change during ...
2
votes
1answer
43 views

How to cast an variable with type abstract class to its subclass?

I'm writing an interface for a method. void method(Node* node); The interface has the code class Node { public: virtual void init(Node* a) = 0; }; The sub class has the code class CNode: ...
0
votes
1answer
29 views

text-orientation in class doesn't apply to tr

i need to show one row's words vertically, for that i've created a class in my stylesheet containing text-orientation:sideways then applied it on the tr , but it won't seem to work, i'm a bit new to ...
0
votes
0answers
22 views

javascript es6 classes: calling a method of a class inside another method of the same class [duplicate]

my code is: PRELOADER_COUNTER = 0; class Preloader { constructor(timeout=15000) { PRELOADER_COUNTER++; this.counter = PRELOADER_COUNTER; this.timeout = timeout; } ...
2
votes
1answer
69 views

How can I create an alias for multiple classes in c++

I have two classes A and B defined in a large code base. I'd like to create a type alias that means "A or B". Note that this class will never switch from being an A to being a B during runtime (and ...
0
votes
0answers
9 views

How can I edit custom Arrays from all Activities

I have an array and an arraylist with custom objects that i want to edit from different Activities. So i decided to make a new class that contains my array and arraylist because sending bundles over ...
4
votes
2answers
42 views

function objects for class methods

I know how to make a function an input argument when the function isn't a method, but I can't figure out how to do it when the function is a method. Here's what I tried: #include <iostream> ...
0
votes
0answers
49 views

Beginner Python for sentiment analysis : AttributeError: 'list' object has no attribute

I am trying to create a sentiment analysis program using a sentiment lexicon. The sentences that will be analyzed are read from a CSV file, and after analyzed, it will be written again in a different ...
0
votes
3answers
48 views

How can I get this dispatching call to work?

I am trying to familiarize myself with object orientation In Ada. Your site helped me with another O-O problem a couple of months ago and I hope that you will be willing to help again. The ...
0
votes
2answers
41 views

associating enum cases will class name

Description I have enums with case names that correspond to class names. I use the enum to populate sections/rows of a UITableView. When a user selects a row, I'd like to instantiate the ...
0
votes
0answers
16 views

my `onevent` custom method does not work in my class

I'm creating a class to manipulate a websocket... class MySocket{ construct(url){ this.socket = new WebSocket(url); } onevent(name, fn){ this.socket.addEventListener(...
0
votes
0answers
9 views

Update original reference of dict variable

I have a really big program with lot of files and I am saving the settings for the program on a class like this. class Options: BACKGROUND_COLOR = "(217, 217, 217)" INPUT_COLOR = "(255, 250, ...
0
votes
1answer
14 views

AttributeError: when solving a system of equations using classes in python

I have a model of two coupled ODEs [dXdt, dVdt] with some parameters (rho, F1, ...) that i want to solve using odeint from Scipy inside a class. When i tried i got an AttributeError as you can see ...
0
votes
2answers
28 views

Why is my edit function adding instead of editing the member?

I'm trying to build a team roster for my class. I got it to where the code won't produce any errors, but when I edit a member, it adds a member to the dictionary instead of editing the member I told ...
3
votes
1answer
45 views

Array of Pointer to Function Inside a Array Of Object

I have a class Ghost that has an array of functions. This class Ghost is an array too. How do I call the functions in main? I cant find a way to call this functions. I have seen some examples but ...
2
votes
1answer
53 views

Typescript error: An outer value of 'this' is shadowed by this container

I had an error in a Typescript class method declaration, but I don't understand how the error message relates back to the bug. The message seems to be saying that 'this' is of type any, but we are ...
-1
votes
2answers
23 views

Why does the method what_are_you output nothing? Syntax mistake? [duplicate]

In this program the output is not what I would expect: class example(object): def __init__(self, foo,bar): self.foo = foo self.bar = bar def what_are_you(): print(foo,...
0
votes
2answers
55 views

Destructors not called?

I am trying to trace this program however for some reason it displays Process finished with exit code 4. and end without calling the destructors? what could be the cause? #include <iostream> ...
-1
votes
0answers
35 views

A full and minimal example for a class (not method) with Python C Extension?

Everywhere, I can easily find an example about writing a method with Python C Extensions and use it in Python. Like this one: Python 3 extension example $ python3 >>> import hello >>&...
0
votes
1answer
35 views

How would I use aggregation with this class (beginner code)?

I would like to understand aggregation so I tried making a simple test code, but it doesn't work in my compiler, sometimes it works online. code for main: #include <iostream> #include <...
3
votes
1answer
104 views

Why do variadic templates behave like this in c++?

I need help understanding this piece of code. There are no loops available, so how can the template, which I know is processed at compilation time, fetch all the arguments, and why did it call the ...
-2
votes
2answers
25 views

Convert milliseconds numeric to time MM:SS then sum

Suggestions of an alternative to the hms package to convert numeric to MM:SS that would give a different class than difftime. Take the following example, I want to convert the variable y in the data....
0
votes
0answers
28 views

Is an interface the same as an abstract class without any method implementations? [duplicate]

public abstract class HelloWorld { method1(); method2(); } public interface HelloWorld2 { method1(); method2(); } For example, what is the difference between the above two in this ...
-2
votes
2answers
46 views

How to fix error C2259: cannot instantiate abstract class

I'm doing an assignment with virtual classes, I need to implement a pure virtual method which later will be implemented in an inherited class. I solved a problem before with pure virtual methods ...
2
votes
1answer
22 views

How can I use the ImageDraw module for a class which is initialised using an Image object

I am new to classes and I wanted to make drawing class for some image manipulation.I am doing this with the ImageDraw module in PIL. I initialised the draw attribute using an Image object and then ...
0
votes
1answer
14 views

use new value of variables in extended class

This is my example code : class Dad { protected $name = 'Alex'; public function setName($string) { $this->name = $string; } } class Son extends Dad{ public function ...
-1
votes
1answer
25 views

How to make my program persistent in python, when i have user made objects?

I'm at the very beginning in Python learning. I can successfully create classes and their instances, now i want to "use" my program to store some user-made objects like: class Dog(): def __init__(...
0
votes
0answers
46 views

2 Dimensional Array for storing a series of different data types in C#

I want to create an array with different datatype of columns for storing a series of data in C# assume we have 1000 rows of data so we could not create a class and instantiate it 1000 times what i ...