FAQ Database Discussion Community


Can I make class accessible by the entire project?

java,class
I am making a small application, for which I want an error system. Just a really simple window that pops up, with the specified error and exit number. For that I have made a "Message" class, that makes a JOptionPane with the message, that all works like a charm. But...

__PHP_Incomplete_Class Object even though class is included before session started

php,class,session
I have a "page" class that on it's construct includes a "shoppingCart" class, starts a session, creates a shoppingCart object, and then sets $_SESSION['shoppingCart'] to the shoppingCart object. I still get an incomplete class when I print_r the session... I thought this only happens when you start the session before...

Solving a java riddle

java,class,oop,if-statement
I'm given class A and class C, and I'm supposed to write class B which makes the output of the main in class C always successful! . Sine there is a random boolean variable, I get a good result only when it's false, when it's true I don't get an...

PHP classes - is it preferable to use normal variables instead of properties?

php,class,oop
For my latest website I’ve been trying to use classes. Mainly to teach myself more about OOP and learn through experience. Whenever I needed a ‘variable’ within my class I created a property, for instance: class someClass { var $valueToUseHere; // Only used internally - can I just use a...

LNK2019 error with simple class [duplicate]

c++,class,calculator,lnk2019
This question already has an answer here: What is an undefined reference/unresolved external symbol error and how do I fix it? 18 answers (Sorry, I know there are many, many posts about this error, but none of them seem to have as simple a program as I'm trying to...

Interpreting hex dump of java class file

java,class,hex
I understand the structure of a java .class file, but when I want to interpret the raw hex data I get a bit lost. This is a hex dump of a class file, excluding the header and constant pool. I understand the header to be the magic number, minor_version and...

Trouble with finding class element names in Javascript

javascript,html,class,getelementsbyclassname
I'm trying to grab the Names of some Class Elements in a document (there are several of them) and rotate through them. The HTML code of the site looks like this: <div class="parent"> <div class="item"> <a class="item-name" href="http://somerandomurl.com">Relevant Item</a> If I wanted to grab the URL I know the solution...

It keeps telling me “Class 'GameScene' has no initializers”

swift,class
import SpriteKit class GameScene: SKScene { var movingGround: JTMovingGround! var hero: JTHero override func didMoveToView(view: SKView) { backgroundColor = UIColor(red: 159.0/255.0, green: 281.0/255.0, blue: 244.0/255.0, alpha: 1.0) movingGround = JTMovingGround(size: CGSizeMake(view.frame.width, 20)) movingGround.position = CGPointMake(0, view.frame.size.height/2) addChild(movingGround) hero = JTHero() hero.position = CGPointMake(70, movingGround.position.y + movingGround.frame.size.height/2 + hero.frame.height/2) addChild(hero) }...

importing haskell module says “not in scope”

class,haskell,instance
I created a Tree structure in a file called Tree2.hs module Tree2 ( Tree ) where data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show) then I imported it and tried to use it as an instance of a class import qualified Tree2 class YesNo...

Access Parent Class without declaring property

.net,class,inheritance
I know this is a very silly thing to ask, but is this possible? Says I have this class Class A { string propertyA; Public A() { // do something here } } Then this : Class B { A classA; string propertyB; } Normally I would do this :...

Invoke classes with Class.forName

java,android,class
I'm following a tutorial, and I face an error; according to the tutorial the code below must work and invoke the activity StartingPoint. However, it doesn't. I simplified the code and just invoke the activity no matter what, and it's working, so I just copy these two. Would you please...

How to automatically stack FLTK's Fl_Input-objects one below the other

c++,class,fltk
I have created a custom-made object based on FLTK's Fl_Input-class that draws to screen an input box and automatically places it below the previous box that was declared. This was implemented by using an "external" (in the sense of "external to the class implementation") counter that is used to compute...

Call known function (with parameters) in class whose name is defined by string variable

java,function,class,variables
I have a bunch of classes of various names and each has a performLogic function that accepts a number of preset parameters (always the same): public final class DoSomeAction extends SetupAction { public void performLogic(param1, param2... I want a way where I can call it like this: String actionName =...

Selenium select with class

python,class,selenium
I have been learning python now for a while, and just got into selenium lately. Anyhow.. I want to find text with class 'fs18' on website, and save it into points_no --> http://i.imgur.com/myt2laM.png Here is my code: points_no = driver.find_element_by_class_name("fs18") But that doesnt work at all.. It just gives me...

Possible to add a new class that can be cast to an existing final class?

java,class,casting,final
I have class A defined in a library: public final class A {blah} And then I want to hack it somewhere using a new class B to substitute it: A a = new A(); A a = (A) new B(); B has all the methods and members in A, so...

C++ compilation error, ambigous operator overloads

c++,class,operator-overloading,ambiguous
I have a template array class overloading both operator [] to access items and operator T * to get direct buffer access. template< typename T > class buffer { const T & operator [] ( size_t ) const; T & operator [] ( size_t ); operator const T * ()...

jQuery function callback does not work in custom class/object

javascript,jquery,class,object,callback
So am a newbie to programming so excuse me if this is a novice question. I am creating a simple wave effect to create an illusion of moving water. I did this with a simple function in jquery and it worked fine. I am learning OOP so my code is...

Laravel5: Access public variable in another class

php,class,oop,laravel,laravel-5
I have a middleware file called LanguageMiddleware.php: ... class LanguageMiddleware { //ISO language codes: public $languages = ['en','es','fr','de','pt','pl','zh','ja']; ... LanguageMiddleware.php is in laravelProj/app/Http/Middleware/ Here's my problem: I have a blade template file called master.blade.php where I'm attempting to output a list of languages @foreach (App\Http\Middleware\LanguageMiddleware\languages as $lang) <a class=\"setLang\" href=\"lang/en\">{{...

Java immutability when defining members in a function called by constructor

java,class,design-patterns,design,immutability
I have class like this: abstract class Parent { protected Parent(Raw rawData) { deserialize(rawData); } protected abstract void deserialize(Raw rawData); } class Child extends Parent { final byte firstByte; public Child(Raw rawdData) { super(rawData); } protected void deserialize(Raw rawData) { firstByte = rawData.getFirst(); } } So basically any child class...

Inner class declaration and initialization

java,class,object,nested,inner-classes
I am used to code in C++, but have to convert a project from C++ to Java. In C++ using data structure is pretty much simple. I am trying to replicate the same thing, but such as a Java inner class and static nested class. After reading several examples online,...

React components as plain JS objects?

javascript,class,reactjs,javascript-objects,ecmascript-6
Does anybody has experience in working with React components as plain JS objects instead of annoying ES6 classes and deprecated .createClass method. Maybe you have some examples of factory functions or similar to share? Thanks!...

Sending a Class' attribute to an outside function in the function call

python,class,tkinter,attributes
I'm trying to generalise a function in my script by sending in the Class' attribute through the function call to an outside function, but since I have to call the attribute self.attribute_name inside the class and object_name.attribute.name outside it, I either get an error that no self.attribute_nameexists outside the code...

introduce c++ into html

html,c++,file,class
So I need to create a data base of a student and his marks in class. I did it by using massive Arrays of objects, but I need to write it in html file like a table, and I create special function save. #include <iostream> #include "windows.h" #include <fstream> #include...

C++ - Template template parameter with default argument doesn't work

c++,class,templates,template-templates
So I have a class of the form: template <typename T, template <typename T> class Container = std::vector> class MyArray : Container<T> { ... } Now I'm trying to instantiate this as template <typename T> class MyClass { MyArray<T> array; } This is producing an error: error: type/value mismatch at...

static variables within javascript functions and how it works under the hood

javascript,function,class,this
I'm having real trouble getting my head around some fundamental concepts in JavaScript so am hoping someone can give me a good explanation of what is happening under the hood in these examples. CASE 1: In this case I use the 'this' keyword in a constructor function: function Counter() {...

How to set a lot a class properties from an object with the same property names?

javascript,class,properties
I'm working in JS and I've got the following object with a lot of properties: var foo = { prop1: 123, prop2: 456, prop3: 789, ... propX: 321 } I want to set a class with exactly the same properties. I can do it like that: this.prop1 = foo.prop1 this.prop2...

Method nonvisibility of same instanceof but differing class

java,class,methods,visibility
I have something like the below: Item var; Depending on user input, it will be initialized as a different class: if (/*user input*/ == 1) { var = new Item(); } else { var = new Truck(); } The classes are defined as: public class Truck extends Item { public...

vector/array bounds check only when a define is declared

c++,class,operator-overloading,operators,element
I've create my own container that is inherited from a vector. I would like to reimplement operator[] in a way that makes checking for bounds decided by a #define. So putting an example, and ignoring template parmameters as they're complicated and irrelevant class MyArray : vector<double> { //... virtual double&...

SigninActivity is not an enclosing class

java,android,class,android-intent,android-activity
I'm trying to change the activity on "onPostExecute" but it doesn't seem to work even though it works on other activities. Here's my code: public class SigninActivity extends AsyncTask<String,Void,String>{ private TextView statusField,roleField; private Context context; private int byGetOrPost = 0; public SigninActivity(Context context,TextView statusField,TextView roleField,int flag) { this.context = context;...

jQuery create a real-time array from multiple inputs with the same class

jquery,html,arrays,class
I have multiple inputs on a page that all have the same class name authority-email. Using jQuery I get the values from all the inputs using the following: var emailObj = {}; $("input[class=authority-email]").each(function () { var email = $(this).val() emailObj = email; console.log(emailObj); }); These inputs can be removed and...

When to use pointer member variables?

c++,class
I realize this is a very basic question but I'd like to see an example of when I should be setting some of my class member variables as pointers. I saw this class definition: template<class T> class Node { public: T data; Node<T> * next; Node<T>(const T& d):data(d), next() {}...

PHP get value from function called by constructor

php,class,constructor
I have a feeling I'm overlooking something simple but I can't figure out how to get a value from a function that is called by the constructor within my class. The below is a very simple example but, essentially, I need to use the userId value on my index.php page...

Map a JSON object to a Javascript class

javascript,json,class
I want to know the "good practice" to map a JSON object to a Javascript instance Class. My example is that I have a database of Cards in a JSON file. Each Card has several attributes. I have a Class Card that has the same attributes plus several methods. How...

Python default/unnamed method

python,class,object
is it possible to create a python object that has the following property: class Foo: def __default_method__(x): return x f = Foo() f(10) > 10 That is to say, an object that when instantiated allows for a method to be called without the need for an explicit method name?...

Initializing a class using threading (Python)

python,multithreading,class,python-2.7
So I have this code import socket def main(): #does a bunch of argument parsing while True: newsock, fromaddr = s.accept() ssl_sock = context.wrap_socket(newsock, server_side=True) threading.Thread(target=tls_listener, args=(ssl_sock,)).start() def tls_listener(ssl_sock): #the thing I want to turn into a class #calls other functions, does some reporting if __name__ == "__main__": main() I...

Issues with Array calling on classes

java,arrays,class
Day two of my journey into the world of java and I have seem to run into a road block even after scouring this wonderfully helpful website. So precontexual 411: I want an array of an unknown length to create its entries by calling on classes. I have the strangest...

How return ID or all from another class with Entity Framework?

c#,asp.net,entity-framework,class
I learning Entity Framework, so don't blame me if this is easy for you I have class HomeNumber.cs [ScaffoldColumn(false)] [Key] public int HomeNumberId { get; set; } //[ForeignKey("HomeNumberId")] //public virtual HomeNumber HomeNumbers { get; set; } [Required(ErrorMessage = "Polje kućni broj je obavezno!")] public string HomeNumberName { get; set; }...

Fighter class does not implement interface member

c#,class,interface
And I am getting this error: Error 1 'Fight.Fighter' does not implement interface member 'Fight.IFighter.Utok(Fight.IFighter)' This is the first time I am trying to learn working with interfaces, so sorry for dump question. Any ideas? I have following code: Interface: interface IFighter { string GraphicLife(); bool IsLive(); int Obrana(int utocneCislo);...

Python class design: explicit keyword arguments vs. **kwargs vs. @property

python,class,oop
Is there a generally accepted best practice for creating a class whose instances will have many (non-defaultable) variables? For example, by explicit arguments: class Circle(object): def __init__(self,x,y,radius): self.x = x self.y = y self.radius = radius using **kwargs: class Circle(object): def __init__(self, **kwargs): if 'x' in kwargs: self.x = kwargs['x']...

Global class comparison with inheritance

c++,class,inheritance,comparison
I am writing global class comparison functions with operator== for a large framework where classes tend to inherit several classes or have deep inheritance (class A inherits from B, B inherits from C, etc.). In order to make things manageable I figured I would have a comparison functions for base...

C++ virtual base classes: parent's copy constructor doesn't get called

c++,class,copy-constructor
I have three classes as you can see in the code below. Notice how I have written the copy constructors. #include <iostream> class Abstract { public: Abstract(){}; Abstract( const Abstract& other ): mA(other.mA){}; virtual ~Abstract(){}; void setA(double inA){mA = inA;}; double getA(){return mA;}; virtual void isAbstract() = 0; protected: double...

How to subclass when creating an object indirectly

python,class,inheritance
I'd like to add some functionality to the html trees coming from lxml. Thus I thought to add a class, using super().__init__() and add the extra functionality, such as adding the depth to each node, adding a boolean for isLeafNode, and implementing a view method. That's where the problem starts,...

Haskell - Could not deduce … from Context error - OpenGL AsUniform class type

class,haskell,opengl,types,uniform
I'm working on making my data types general instead of taking in the OpenGL type GLfloat. So I started making it take in type a and then just replacing everything with that. Now, I've come to a point where I'm setting uniform variables, but they take in GLfloat's. I'm using...

How would I refer to a specific html element that was just made in Javascript and get its value?

javascript,html,class,eventlistener
My program takes in user input of a string and checkbox and builds up a list to be displayed. (Check-list basically) Each list element consists of a string variable and a check-box input but I can't refer to a specific checkbox if say the third one would be ticked since...

Silex namespace : class MainController does not exist

php,class,namespaces,autoload,silex
I try to use Silex Framework, but i have a problem with namespaces I think. when I instanciate my class MainController i have the following error : Class "MainController" does not exist here the namespace declaration in my MainController.php : namespace App\Controllers; use Silex\Application; class MainController implements \Silex\ControllerProviderInterface { .......

Downcasting doesn't work and functions called from object own class instead of where the function is (Java)

java,class,oop,methods,casting
i have this classes hierarchy: public class Musician { private String name; public String instrument; public Musician(String name, String instrument) { this.name = name; this.instrument = instrument; } public String getName() { return name; } public String getInstrument() { return instrument; } private String getClassName() { return "Musician"; } public...

Class enumerator values cannot be passed as parameters to another class's function

c++,class,parameters,header,enumerator
In a program I'm making, I'm trying to get a certain class to pass data to another class's function as a parameter. This data happens to be a variable from the first class's member enumerator. But I'm getting a lot of errors. The code below is an example of what...

C++ inheritance and virtual funcions

c++,function,class,inheritance,virtual
Here is my task: Design classes Circle and Square which are inherited from class Shape (which contains center of gravity which is common characteristic for all shapes, function for moving center of gravity for specific value and virtual functions circumference, area and read). Classes should have specific functions for calculating...

Can't enter the Dictionary<> code in C#

c#,class,dictionary
It seems that no matter where I enter Dictionary<> in my code or class, it just wont be accepted and it produces an error. I get Invalid token for brackets and parenthesis and I get System.Collections.Generic <Dictionary<String, MediaClass> is a type but used like a variable I've done various searches,...

Python class cannot be instantiated through Terminal

python,class
For educational purposes, I want to show how classes work in Python. My demonstration is to go to the terminal, use Vim to create a new file classy.py and then run Python on the terminal. I begin typing vi classy.py, entering insert mode with i, and then I type: #...

static class with so many request at same time

c#,class,c#-4.0
I created a static ip and log class. the ip class find out the users ip address and log class log it into a text file. every thing work just fine but i wonder what happens if so many requests came at a same time? i mean the both classes...

Why don't I get any output?

c++,class,methods,output
I am trying to write my first OOP code in C++, but for some reason I am not getting any output. I am trying to create a class that contain a method getSquare() that accept an int n and returns the number squared. Can anyone tell me where I am...

PHP: how to used a class function?

php,class,object
I'm quite new and having some trial and test creating a class and objects. Here's my script: <?php class testingm { private $t; public function __construct($file) { $this->t = fopen($file, 'rb') } } $test = new testingm; $s = new file($_GET['n']); ?> the script says Warning: Missing argument 1 for...

C++ and packed struct

c++,class,struct
I have database project that I want to move from C to C++. In this C project I have lots of small packed structs, that I write directly to file or read from mmaped file - e.g. directly from memory address. I need the class in-memory representation, to be exactlybthe...

How to accumulate a value in java?

java,class,constructor,instance,accumulator
Right now, I'm learning all about class, constructors and instances. I've made a small bit of code in java and I'm stuck with this particular code. ***MY CODE OUTPUT IS SUPPOSE TO BE LIKE THIS: OUTPUT Enter amount:500 Do you want to enter amount again?(y/n):y Enter amount:45 Do you want...

My simple php class not working [closed]

php,class,oop
I wrote a simple class. but its not working. Something is wrong. can't find error line class Host { public $scheme; public $hostname; public $www; function __construct(string $scheme,string $hostname,string $www) { $this->scheme = $scheme; $this->hostname = $hostname; $this->www = $www; } public function get_URL() { return $this->scheme.'://'.$this->www.$this->hostname; } } $site...

Convert String to the name of a array in another class

java,arrays,string,class,int
I'm a amateur programmer and I'm wondering if it's possible to solve a problem in a specific way. public class Stats { public static int[] Hero = {20, 20, 10, 10, 10}; public static int[] Villain = {20, 20, 10, 10, 10}; public static void name(int[] name) { //If you...

How do I use a HashMap from another class or function?

java,class,hashmap
Here is a working code example. Thanks to @markspace for providing me with it. The code here makes a hashmap and inserts values in it. public class RpgPersonExample { public static void main( String[] args ) { Map<String, RpgPerson> team = new HashMap<>(); team.put( "Sgt. Mayhem", new RpgPerson( 100, 10,...

PHP, how to set class variable value from function

php,class,constructor
I am creating a class with variable, as you can see from the code below, I am want to access $allen = new guest(...); echo $allen->userName; instead I have to use this $allen->getUserName(); but since username won't change after the class is created, is there a way to do this?...

C++ call a child's method from a vector of parents?

c++,class,inheritance,polymorphism
Say that you have the following class: class Parent { // methods and members go here }; then you create a child based on the parent: class Child : public Parent { public: someFunction(); }; Now class Parent doesn't have someFunction() but class Child does. Say that you have a...

Read constants from command line as global variables

c++,class,constants
In my program I have defined a header constants.h where I define constants that will be used in my program, which contains multiple classes. No I would like to read the constants from the command line and initialize these constants such that they can be used in the same way...

if condition for multiple methods in a class

python,class,methods
I'm writing in python to get a better feel for good practices when using classes. I've written a few methods for a couple classes; dog and person. I have introduced a new method for dog called die, defined below: def die(self): if self.owner: self.owner.pets.discard(self) self.owner = None self.dead = True...

Efficiency penalty of initializing a struct/class within a loop

c++,performance,class,loops,struct
I've done my best to find an answer to this with no luck. Also, I've tested it and don't see any difference whatsoever in an optimized release build (there is a difference in debug)... still, I can't imagine why there is no difference, or how the optimizer is able to...

Class atributes not updating [node.js - express ]

javascript,node.js,class,express,neo4j
I have some troubles with a .js Object's atribute which is not updating when i ask it to. I'm new in the javascript world, so i hope my issue won't be tricky. First of all, this is a part of my Node class : Node = function (label, vals, db,...

What makes the object.prototype to the constructor function if he has no name? [duplicate]

javascript,function,class,inheritance,prototype
This question already has an answer here: Defining a Javascript prototype 5 answers My following code is this: var triangle = {a:1, b:2, c:3}; function constructorFunction() { this.color = "red"; } constructorFunction.prototype = triangle; I know that the prototype keyword extends classes in this syntax: Object.prototype.method = function() {}...

How can I see the code of a imported class in eclipse?

java,eclipse,class
I want to see the source code of implemented classes in a package. I know how to access (by CTRL+click in the method or presing F3) but when I do that, it appears a message "source not found, The source attachment does not contain the source for the file..." I...

Are interfaces a valid substitute for utility classes in Java 8? [duplicate]

java,class,interface,java-8,utility-method
This question already has an answer here: Java 8: Interface with static methods instead of static util class 4 answers For the past decade or so, I've been using the pattern below for my Java utility classes. The class contains only static methods and fields, is declared final so...

implement __rmul__ from both sides, python

python,class,operators
I there a way to implement rmul so that it works in both directions? I'm using mul to multiply two vectors a and b of class R3 element by element. Later I want to be able to multiply each element by a number with an operator like 2*a and a*2....

ToInt32() conversion [on hold]

c#,class
Like ToStr() method, I am trying to convert to Int32() as following: class customer { public int ID { get; set; } public string Name { get; set; } public override int ToInt32() { return this.ID; } } Compiler is complaining about ToInt32() as no suitable method to override. Help?...

How to check if a variable is an ES6 class declaration?

javascript,class,prototype,ecmascript-6
I am exporting the following ES6 class from one module: export class Thingy { hello() { console.log("A"); } world() { console.log("B"); } } And importing it from another module: import {Thingy} from "thingy"; if (isClass(Thingy)) { // Do something... } How can I check whether a variable is a class?...

How to run .java file with Variable Name

java,class
I'm trying to make a program based off of the Pebble Smartwatch Operating System. I have a text file called PebbleOS_Faces.txt which has all the names of the different watch faces I will have on the watch. I use PrintWriter to convert the content into a .java file, and then...

Is there a way to access the variables/fetch the assigned values of the caller class in a method of the called class?

java,class,static
This is similar to the question : Is there a way to access the variables of the calling class in a method? But I am not quite able to get the exact answer. What I am trying to do: class A{ m() { int a=8; new B.m1(); } } class...

How to share an instance created in main with a class in another module

python,class,share,instance,global
I am having a problem with how to share a class instance between modules. Below is not the actual code, it is a simplified representation of what I'm trying to do. The variable in question is thePlot. If I make it a global, I get 'global name not defined' type...

Is a Java class variable a reference to a class object?

java,class,object,reference
I know such question has been asked before but I couldn't find a satisfactory answer. Assume a java class : class Foo{ public int k; Foo(int a){ k=a; } } class My{ public static void main(String args[]){ Foo obj = new Foo(5);//1 obj=new Foo(8); //2 } } I want to...

What is the class of keywords like def, alias, and begin in Ruby, if any?

ruby,class,inheritance,keyword,superclass
As far as I understand, everything in Ruby is an object, and every object has a superclass, except BasicObject, which is at the top of the inheritance tree. What is the superclass of keywords like def, begin, and alias?...

Vector of objects from different classes

c++,class,object,inheritance,vector
I'm trying to create a vector containing objects from different classes, derived from a base class. Following answers to this question I've the following code which tries four different ways (commented out below); none of which will compile: class observable { public: virtual void observe(alglib::complex_1d_array)=0; observable() { } }; class...

Object Oriented Python - rectangle using classes and functions

python,function,class,oop,methods
I am creating a program in Python that will utilize object oriented programming to print the properties of a given rectangle. The project has these given constraints: The purpose of this lab is to give you practice creating your own object. You will be given a main function that expects...

Scala classes and List

list,scala,class,add
So my short code snippet looks like the following: Source.fromFile(fileName).getLines().foldLeft(List[CsvEntry]())((csvList, currentLine) => currentLine match { case pattern(organisation,yearAndQuartal,medKF,trueOrFalse,name,money) => new CsvEntry(organisation,yearAndQuartal,medKF.toInt,trueOrFalse.toInt,name,money) :: csvList case default => csvList The "fileName" is only the Name of the file, but it doesn't matter for my question. And my csvList is defined like this: type...

Best way to get variable from another script

c#,class,unity3d
I'm working on a 2D game and I have many c# script. Some variable like Speed influence to a lot of gameObject's and script. I want to all of these script's read Speed variable from just one script and I do this with property and it worked very well. But...

Understanding inheritance in practice. Printing values of an instance

python,class,inheritance,printing,instances
I have a class of Agents with a working __str__ method. I have a class of Family(Agents). The Family is structured as a dictionary with the Agent ID as key. After allocating agents to families, I iterate over my_families: When I print members.keys(), I get the correct keys. When I...

Understanding default access modifiers

c#,class
I am confused about access modifiers, so I thought I would ask a couple of quick questions for clarification: Is it always the case that in the absence of access modifiers for data members of a class, the default is private, though the class itself is internal? class A {...

Attempted to load class “COM” from namespace -Symfony2

php,class,symfony2,ms-access
I am developing a web using symfony2 framework. In this web the users upload file(.mdb). The web read the file and if the information is correct it pass to database.(This is the idea) The problem is that i try to used "COM class of PHP". First i think that i...

Inject data from one type object to another

java,class,object
I have two different classes lets say: public class Customer { public String Name; public String Surname; } And public class CustomerExtended { public String Name; public String Surname; public int number; } Now lets say I have an array of Customers and I want to inject it into array...

undirected weighted graph data structure in c++

c++,class,c++11,data-structures,graph
I am learning C++ and I appreciate your support by answering my question to help me to understand fundamental concepts. I am sure I need to learn many stuff, but I need a some advice to help me to find the right way. The problem I have is explained in...

can es6 class have public properties as well as functions?

javascript,class,properties,public,ecmascript-6
All the examples of classes I see are class myClass{ constructor(){} someFunction(){} what I want to add is someObject {myvalue:value} } this doesn't seem to compile. An old fashioned object would be { somefunction: function(){} someProperty: {myvalue:value} } is this not possible in es6 classes?...

In Java, How do I cast a Realm Object into the class I wish to write to the Database?

android,class,object,casting,realm
I am currently working on a project where my Database has a very large number of tables (Approx 60 total). I am working to create the Database Helper class that will function as the writer/ reader to/ from the database. And example of my write method would be this: public...

Can you put a pimpl-Class inside a vector

c++,class,c++11,smart-pointers
I have a class implemented using the PImpl Ideom: class FooImpl {}; class Foo { unique_ptr<FooImpl> myImpl; public: Foo(); ~Foo(); }; And now I want to put this into a std::vector void Bar() { vector<Foo> testVec; testVec.resize(10); } But when I do that, I get a compiler error (VC++ 2013)...

Java: set and get methods for strings

java,class,object
I have to write a program which uses appropriate get and set methods to output the following: This person is John Smith (21, male) So far, I have reached here: public class Person { private int age; private String name; private String gender; public void setAge(int age){ this.age= age; }...

jQuery/Javascript get classes of multiple elements to show an element with this class

javascript,jquery,class,if-statement,jquery-selectors
I'm struggling with a jQuery live search. First of all the live search update with the following code works. //live search function function live_search(list) { $("#search") .change( function () { //getting search value var searchtext = $(this).val(); if(searchtext) { //finding If content matches with searck keyword $matches = $(list).find('a:Contains(' +...

Does a class without fields have a special name?

java,class
What is a class without fields called? I'm a beginner in programming Java and I'm trying to understand and learn about classes, so i have the following class "DalUser" that doesn't have fields, only methods, like validateSession in a folder called Dal: import com.app.Be.BeUser; public class DalUser{ public BeUser validateSession(String...

Function with enum return type can not be resolved in a class of C++

c++,class,enums
My check.h file has an enum as a private variable. I do not know what to do to declare enum as a global entity. I declare a function in check.cpp with enum return type. But it is giving the error as follows. Multiple markers at this line Type 'TStatus'...

Should i instantiate a new model?

c#,asp.net-mvc,class
MVC. I am passing data to the view in my model. In my repository I map the linq result to the model. In the controller I send the data. Which one should I do: List<PersonModel> people = new List<PersonModel>(); people = repo.GetPersonList(); return View(people); Or List<PersonModel> people = repo.GetPersonList(); return...

Calling an object and its method from another object class method

javascript,class,oop,object,methods
I have created some classes/objects for some animations. I created a class called Navigation(), and another class called Stars(). Each of the classes have their own methods and objects associated with them. I have created a method within the Navigation() class that attempts to run a method and the object...

Using classes in any type of programming? [closed]

html,html5,class
In html programming, do websites require classes even if some websites don't require or don't contain java script? Is it OK to not need standard classes in an html file or does every website that is on the internet uses some sort of class within their html?

Why aren't the references to the private var's not being updated?

javascript,class,scope,closures
The add method isn't working like intended. When I have 2 time object t (all 0's), and t2 (1 minute). When I add t2 to t, t doesn't change BUT when I call my toString method on t it gives me the expected value. Here is what I mean if...

Passing function name as callback doesn't work as expected in my class

php,function,class,callback
This seems straightforward, but the below code is giving the following error. Any suggestions? usort() expects parameter 2 to be a valid callback, function 'cmp' not found or invalid function name My code: function cmp($item1, $item2) { return strcmp(strtolower($item1->last_name), strtolower($item2->last_name)); } public function get_people() { usort($this->my_array, 'cmp'); } ...

Do scala classes have “self” like Python?

python,scala,class
For example if I have object Solution { class myClass(A: Array[Int]){ val something: Int = A.length; val another: Int = something/2; val someName = "blah" ... ... Do these variables "exist" only for a particular instance of myClass or are they "class-wide" variables shared among all objects? If it's the...

Does a class without methods have a special name?

java,class
What is a class without methods called? I'm trying to understand and learn about classes, so i have the following class "Variables" that doesn't have methods, only fields, like the field "Server" in a folder called "utilities": package com.abc.app.utilities; public class Variables { public static String Server="http://192.168.1.29/"; } then this...

Is it bad practice to have a static class that does not instantiate objects

java,class,oop
I read that a class is like a blueprint for an object. So is it considered bad practice to declare a class but then in the program, never actually create instances of the class (but just have static methods in the class)?

avoiding duplication in the assignment operator of a derived class

c++,class,assignment-operator
Consider the assignment operators in classes Parent and Child, below. #include <iostream> class Parent { public: Parent(){}; virtual ~Parent(){}; Parent& operator=(const Parent& other){mP = other.mP; return *this;}; void setP(double inP){mP = inP;}; double getP(){return mP;}; protected: double mP; }; class Child : public virtual Parent { public: Child(){}; virtual ~Child(){};...