I have created a class in VBA which I would like to have some pre-set values associated with it. I am new to classes, and am wondering what is the best (/a good) way of structuring my VBA code within the class object, so that I can access these defau
I create a two pointer object of a class 'myclass' myclass *obj1,*obj2; can I compare these two objects using comparison operator and pointer expression i.e *obj1==*obj2 If yes, how does it happen? If not, why isn't his allowed?If yes, how does it ha
I'm trying to build some programs for fun and learning. I have the problem below: function Hero(name) { this.name = name; this.addItem = function(item) { this.items = this.items || []; this.items.push(item); }; // .... this.viewItinerary = function()
There is a way to know if a variable in swift is an instance of a class or a struct? I'm trying to do a deepCopy but I'm only interested in doing that if it is an instance of a class, not a structI found a way to do this func getDeepCopy<T>(object:
I want to use an if statement to select the value of a subclass in an image slider. If the input value is 'yes', it changes the text color. Javascript: $('document').ready(function(){ if $('.slide-active').find('.black').value = 'yes'){ $('.slide-tit
What I'm trying to do is to read triangle coordinates from a text file named "p102_triangles" whose data is like this: -340,495,-153,-910,835,-947 -175,41,-421,-714,574,-645 -547,712,-352,579,951,-786 419,-864,-83,650,-399,171 -429,-89,-357,-930
I want the constructor of a class to be able to pass two types of parameters, then inside the method do some stuff based on the type of the parameter. the types would be double and String[]. the class and its constructor is something similar to: publ
I always pad my structs in C to get the maximum performance (good memory alignment). // on a x86_64 struct A { int64_t z; int32_t x; int16_t y; // we don't care the uint8_t position, as they are 1 byte wide. uint8_t s[8]; uint8_t t[4]; } But if I dec
This question already has an answer here: Use of 'prototype' vs. 'this' in JavaScript? 14 answers Which of the following cases is better for performance or proper techniques? CASE #1 function SomeClass () { this.someVar = null; this.someFunc = functi
The title is pretty much self explanatory, but I think this is better explained with an example. class Dog(): def __init__(self, name): self.name = name def get_name(self): return self.name def get_color(self): return body_color() class personality_1
In a program like: package testing; import MarcoLib.Mouse; import MarcoLib.Timings; public class Testing { /** * @param args the command line arguments */ public static void main(String[] args) { Mouse.pressMouse(1); } } Is there a way to call Mouse.
I have to create a template function that searches an element in a map variable. If the element exists, the function must return it. Otherwise i must return NULL. template <class K, class E> E dictionary<K,E>::research(K key){ //map<K,E>
This question already has an answer here: chaining classes for .hasClass(); 3 answers JQuery .hasClass for multiple values in an if statement 10 answers I am now practicing my JS skills and Jquery. var clickcheckboxcount=0; var clickedcheckboxname =
nop = 0 patron = list def createnew(firstname, lastname, phone, age, gender): name = (lastname.lower() + ", " + firstname.lower()) patron.append(patrons(name, phone, age, gender)) nop += 1 class patrons(): number = 1 def __init__(self, name, pho
I have an object and client class created which prints coordinates in order of their distance from the origin. The client class asks the user how many dimensions they want the array to have (x,y or x,y,z) how many points they want generated, and a ra
I am creating a new class in UserList, and trying to override the add, append, and extend methods so that duplicate values will not be added to the list by any of these operations. So far I have started with trying to override the append method and w
Newbie here, I need help with a website I'm creating. I have a class that does some analysis on some text that is input by the user, the class then finds an appropriate answer and sends it back to the textbox. (in theory) Problem is I don't know how
I have been told that declaring dynamic attributes within a classes scope is not the 'Python Way' but I do not understand why. Could someone explain this to me or point me at some documentation as to why this is a bad thing? Honestly, I thought this
Assuming defintion: case class IntegerWrapper(i : Int) and being in a situation that potentially large amounts of IntegerWrapper instances with i=[0..N> may be created what does one have to do to: Map this range to a fixed set of singletons [IntegerW
I have many IF sentences that each start a function. Is there an obvious way to write this code much simpler? Every IF starts different function, but it still looks like an overkill. if ($this->machine == '' AND $this->date_from == '' AND $this->
I tried to create seperate accelerometer class that holds values of accelerometer and I can acces them from any other class whenever I want, but it doesn't seem to work. Here is my Accelerometer class: import android.hardware.Sensor; import android.h
class Base{ //... public: int get()const{ // const // Do something. } int get(int x){ // Do Someting. } //... }; class Derived:public Base{ //.... public: int get(){ // not const (not the same signature as the one is the base class) //Dosomething } /
The following code compiles and it seems to run fine: class Test { private: const unsigned MAX; public: Test (const unsigned int n) : MAX(n) { } void foo () { int array[MAX]; ... } }; but is it really OK? I mean: Test a (3); Test b (8); does array ac
I'm refactoring a single 3000+-line class with a tangled web of conditionals and switches into a set of worker classes. Previously part of the constructor would select which "type" of thing to use via code like the following: enum Type { FOO, BA
I've just started using OOP PHP and ran into a question. I've set up a generic mysql class that allows me to connect to a database and has some functions to obtain records from a table: class mysql{ //some lines to connect, followed by: public functi
We've just started learning Java for my degree and I've been given a folder with various Java classes in, each in their own .java file, with the file name the same as the name of the class it has it in. There is one file which hosts a public class wh
I would like to use the same code for copying files to an FTP server, and through USB. I've already written some code, which as of now uses functions from the System.IO namespace. To minimize code duplication, I've listed the functions which I need f
Data.XX.NewValue := Data.XX.SavedValue; Data.XX.OldValue := Data.XX.SavedValue; I need to do the above a large number of times, where XX represents the value in the class. Pretending there were 3 items in the list: Tim, Bob, Steve. Is there any way t
What is the issue with this code? Here we have two files: classA.h and classB.h classA.h: #ifndef _class_a_h_ #define _class_a_h_ #include "classB.h" class B; //???? class A { public: A() { ptr_b = new B(); //???? } virtual ~A() { if(ptr_b) dele
Class c = new Class( { Prop = "Initial" } ); I have the class above. How would you create a method to modify it? public Class ModifyIt(Class c) { c.Prop = "changed"; return c; } or public void ModifyIt(Class c) { c.Prop = "changed