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.

1
vote
2answers
22 views

Some explanation about calling PHP function in class

I know it is basic php question but I had something that I didn't understand, it is about the return; when I call a function, the bellow code is just an exemple. Case : In TEST2 when I do my check ...
1
vote
0answers
25 views

Confused about the buildin method __str__() on integer [duplicate]

We know that str() method defined in the object class allows us to convert an object into a string. It works fine for some Python's buildin data classes, for example, if you invoke the str() method ...
0
votes
4answers
57 views

How to transfer a variable from main method class to another class?

Okay... in my main class, I ask the user to enter an input int value. Now I need to take this value to a different class to do some coding. How? Code from main class: neededValue = keyboard.nextInt()...
-1
votes
0answers
19 views

Unable to call class from C++ using atom: expected unqualified-id before ‘)’ token

I am new to C++ and I am currently trying to deal with classes in Atom. I am following this tutorial, and have installed the header-implementation package because it seemed necessary (I may be ...
1
vote
1answer
22 views

Should you have a function run when you initialize an object class in Python?

I have a project I am working on, and I have a Python Class object that works fine, but I'm curious if it's designed properly when I call the __init__ method. Right now, I have a function (...
3
votes
1answer
42 views

Creating a Template Class that abstracts the data types

I am writing a set of algorithms to create a simple unit test framework. The class titled UnitTest is instantiated with a character string titled strng that describes the test being conducted. The ...
0
votes
3answers
32 views

How to use class functions in another class?

How can i use class instance in another class like a pointer in C++ to class instance functions? Example: class A { constructor() { this.block = []; } method() { ...
0
votes
2answers
24 views

How to add a class in a method - VUE.js

Basic question but still I cannot figure out how to add an extra class based on @click. I still get error: Cannot read property 'add' of undefined" methods: { hideItems() { document....
1
vote
1answer
28 views

Suitability of setting default attributes for user classes?

I have a decent level of programming, and get much value from the community here. However I have never had much academic teaching in programming nor worked next to really experienced programmers. ...
-2
votes
0answers
17 views

Void type not allowed here [duplicate]

Here is the program i'm trying to write: Write a Student class that has: name: a String bannerId: a String 3 constructors A constructor that name and bannerId A constructor that ...
-1
votes
0answers
15 views

Creating a instance in the main class throw a compilation error, i don't know what to do

I'm doing a very simple neural network (just 1 neuron) in java, with a GUI. It takes 2 input numbers and compute a output. I have some sliders for adjust the weight of the neuron inputs. When running ...
3
votes
4answers
54 views

How to make static_assert block re-usable in template classes?

Say I have a template class that makes multiple static_asserts: template <class T> class Foo { static_assert(!std::is_const<T>::value,""); static_assert(!std::is_reference<T>...
0
votes
1answer
24 views

How can I use the value of a previous object property inside another property of the same object when I am declaring it

I have a class which returns an object with its properties. I would like to access to the value of a previous prop inside the constructor. I have next working code: class KafkaConsumer { ...
0
votes
1answer
27 views

In “inherit”, I'm having trouble with the 'return' code

The following code does not have any problems. It works smoothly. class Animal{ constructor(name,age){ this.name = name; this.age = age; } getPrint(){ console.log(`name: ${...
-1
votes
1answer
35 views

How to propertly use function arguments in python class? [on hold]

I'm new in python and I don't understand many instructions. So I don't understand why after running the code below output is empty. I would like to code a simple rock paper scissors game with classess....
0
votes
0answers
33 views

How to access a function using an object which is stored inside a dictionary in python?

I have created a class which has an object named entity inside it. The objects has a set of attributes and functions inside. In a different python file, I have created a dictionary of entity objects. ...
0
votes
0answers
15 views

PhpUnit Reflection Class Does not exist, event thout I correcly PSR-4 Autoload

I have the following test (located in tests/DropboxFactoryTest.php): namespace PcMagas\Tests; use PcMagas\DropBoxFactory; use PcMagas\Exceptions\FileNotFoundException; use phpmock\MockBuilder; use ...
-1
votes
3answers
68 views

Why does the child of this class does not print?

I have made a class that is supposed to handle a subprocess but when I put a test print inside nothing happens, can someone tell me why ? I have tried different types of print and combinations of ...
2
votes
3answers
51 views

Order of execution with python class

I was writing a small python script to understand a concept and got another confusion. Here's the code - x = 5 y = 3 class Exp(object): def __init__(self, x, y): self.x = x self....
0
votes
0answers
28 views

Add XAML element from another class

I want to add a TextBlock to a StackPanel in the MainWindow from another class. If I just try to create a new TextBlock element inside the class, I get the error that it must be an STA Thread. Then I ...
0
votes
0answers
24 views

Get current tensorflow variable value from class

I have defined the following class for linear regression, and in order to see my parameters I tried to get the values, but it does not work, since the weights are a variable and cannot be evaluated ...
-1
votes
0answers
15 views

Accessing global model variables in sub class python

I am writing a code that does basic modelling and then it passes the model to the calling python file. Even though the variable I declared is global, whatever I change in global variable is not ...
0
votes
2answers
31 views

NameError while calling a class method

trying to understand classes and methods in Python 3.7. I keep running the code below, but keep getting this NameError, associated with the points variable I established in the initialize method of ...
0
votes
0answers
13 views

Using a method within another method in a javascript class [duplicate]

I wanted to take an OOP approach to making an ajax request to an API. I wanted to create methods to modularize my code. One method making the request, one method building the DOM list of names. The ...
0
votes
2answers
28 views

Method referring to a pulled in packaged's method moves out of scope when put inside an objects method

When I put a method that refers to a pulled in package inside another method it leaves scope and fails. What is the proper way to do this. I tried playing with the 'self' but am new and that did not ...
0
votes
1answer
38 views

How using second class in main class as method

My main class Desktop don't return buttons of second class .Why is this happening . I was creating method add_button in main class not using second class, but part of initUI stop working because of ...
1
vote
1answer
19 views

Ensuring the absence of an __init__ function in Python

I'm writing a plugin-based application. Part of the specification for a plugin is that a plugin must not implement the __init__ method, as any initialization needs to be handled by the plugin manager, ...
0
votes
0answers
14 views

Undefined symbol for architecture in only two of 5 identical methods

I´m trying to use a specified class in another one declaring it like static parameter. The first class is the DNI or NID(in English) class and the second one is the counter. The program has to count ...
0
votes
2answers
31 views

How would I use multiple classes together without inheritance?

I am currently learning classes and applying it as I go but I have come across an issue I am not sure how to get past: I do not know how would I define a character having a weapon. I have looked ...
0
votes
1answer
37 views

Getting field value by class instance

I learn to write code in C# and I would like to know whether there is an option to get value of the field inside class just by using instance name. I would like it to look like that: class foo{ ...
0
votes
1answer
31 views

How to bind an array of json objects to an array of javascript class in ES6

I'm working on a single page application that connected to a restful web service on Reactjs my problem is not related to Reactjs it's just about a design pattern that should implemented correctly on ...
-1
votes
1answer
34 views

how to create a c++ function which create new object every time user input new data?

i'm new in c++ and i've been given an assignment where to create a program that can entry Employee Name, Work Hour, Overtime Duration. There is a menu Insert Employee, View Employee where option view ...
1
vote
3answers
28 views

How can i find max element index for a specific value in list composed of class objects?

I want to find a maximum elements index in a nested list for each row. I got this error: maxe = array[i].index(max(e_object.x for e_object in array[i])) ValueError: 5 is not in list class ...
0
votes
1answer
42 views

Is it possible to place all Variables and Methods inside of a Class?

Sorry for the beginner question. I followed a quick tutorial to make a Ruby Quiz, which I'll explain. I created a class as below: class Question attr_accessor :prompt, :answer def ...
0
votes
2answers
55 views

How would I give CSS property to a cloned element as Javascript?

I'm trying to give translateX() property to cloned element which is called this.firstClone as javascript. The problem is this.firstClone doesn't refer to the cloned element even the value itself makes ...
1
vote
1answer
29 views

how to create a new instance of a class from within a method? [duplicate]

I extended the dictionary class to create my own and now I need to have a method which creates a new blank instance of the class and initialises it with the needed values. The problem I'm facing is ...
0
votes
0answers
35 views

How to get a React component class from a string that contains the class name?

Note: This question is not a duplicate of React / JSX Dynamic Component Name. I am already aware of the solution used there in the accepted answer and if you read my question below, I am using a ...
1
vote
1answer
23 views

JavaScript: How to fix an instance not being assigned property values properly

I create an instance of my Piece class and am trying to print out the value of the instance's quantity, but I keep getting undefined. I look in the Google Chrome console, and console.log(temp) fine, ...
0
votes
0answers
49 views

Is there a way to read csv files into an array of objects of a custom defined class using fstream?

I am attempting to pull data from csv files into an are of a class I built. However, when attempting the files are found, but it my arrays are left empty. CSV is formatted in following [string] [...
-1
votes
0answers
18 views

error with build constructor to object - using pointer to pointer and classes

I am a student in computer science - first year. I study object oriented programming - i the course i got a homework. While writing the code - I got stuck - it seems that I have syntax errors - I ...
2
votes
2answers
30 views

List integers to string using classes

I want to write a class for vectors, and I need to be able to cast the integers in the list to a string and print them. Example: [1,2.5] --> "<1,2.5>" This is what I came up but its not working, ...
-1
votes
0answers
15 views

If The Button Appear Auto Click on It with Class Name in Node JS

My code automatically refreshes a website with a setInterval and if the button appears it clicks on it. It will identify the button by the name of the class. I have this error, ReferenceError: ...
-1
votes
0answers
35 views

How to share array of vector between classes

I would like to get an array of vectors from a class to use it in a separate source file. I had no luck with an array of boolean neither. I have tried to get it through a public method. It works with ...
0
votes
0answers
40 views

Python chat application using tkinter. Mainloop problem

I tried to write a chat application using tkinter and python 3. I would like to combine the functionality of the Server class, which allows to communicate with others, with graphical user interface ...
1
vote
0answers
24 views

why “this” works inside render() but not on other function [duplicate]

I currently learnign React. I was introduced to a problem with "this" keyword. Basically i understand how it works but in react or maybe in ES6 class i m finding my self confused. For example i have ...
-3
votes
0answers
20 views

How to begin car rental project [on hold]

I need to make 3 classes. A user, admin and buyer.The buyer needs to have a unique id, firstname,lastname,date of birth,phone number. admin and buyer inherit class USER. The problem is i don't know ...
1
vote
1answer
55 views

How to delete Javascript created class?

I have some code: let new_user = new User({ username: 'someone' }, isValid => { if (!isValid) { // I need to delete this user class } }) I tried to do new_user = null, but ...
0
votes
1answer
27 views

How to name a composite class like this?

Our team are using Spring Boot 2 with sql2o as db library. In the paste in our services, for trivial methods, we simply call the repository and returns the model. For example, if I have a Supplier ...
0
votes
2answers
43 views

Position: sticky; not working no matter what

Trying to get a class to remain sticky and constantly be in view when the user scrolls down the page, but doesn't seem to work no matter what. I tired: .entry-summary{ position: -webkit-sticky; /* ...
-3
votes
0answers
45 views

How i can SqlDataReader from DataTable using Stored Procedure?

i have class called DataAccessLayer and contain this code : //Read Data From DataBase public DataTable SelectData(string stored_procedure, SqlParameter[] param) { SqlCommand ...