class

Arithmetic Operators vs Methods in Class Design Guidelines

I have many math types like Point3, and I am running into the dilemma of implementing operators, instance and static methods for arithmetic. So say the type is Point3. Where a, b, c is a Point3, I sure wanna be able to say: c = a + b; But should I also implement: c = Point3.Add (a, b); And this: c = a.Add (b); To me #3 is usele...

C# - How to access internal class from external assembly

Hi, Having an assembly which I cannot modify (vendor-supplied) which have a method returning an object type but is really of an internal type. How can I access the fields and/or methods of the object from my assembly? Keep in mind that I cannot modify the vendor-supplied assembly. In essence, here's what I have: From vendor: intern...

How to use classes derived from Python's list class

This is a followup to question 912526 - http://stackoverflow.com/questions/912526/how-do-i-pass-lots-of-variables-to-and-from-a-function-in-python. There are lots of variables that need to get passed around in the program I'm writing, and from my previous question I understand that I should put these variables into classes, and then pas...

Unique class type Id that is safe and holds across library boundaries

I would appreciate any help as C++ is not my primary language. I have a template class that is derived in multiple libraries. I am trying to figure out a way to uniquely assign an id int to each derived class. I need to be able to do it from a static method though, ie. template < class DERIVED > class Foo { public: static int s_id...

NameError using execfile in python

My application has a button to execute a python script dynamically using execfile. If I define a function inside the script (eg. spam()) and try to use that function inside another function (eg. eggs()), I get this error: NameError: global name 'spam' is not defined What is the correct way to call the spam() function from within eggs...

How can I use a different object inside of a class?

If I create an object inside of the main scope: INDEX.PHP: $db = new database(); Then how can I use this same object inside of a completely different class? ANYTHING.PHP: class anything { function __construct(){ $db->execute($something); # I want to use the same object from INDEX.PHP } } Would I need to make $db a...

C# Help: Sorting a List of Objects in C#

public class CarSpecs { public CarSpecs() { } private String _CarName; public String CarName { get { return _CarName; } set { _CarName = value; } } private String _CarMaker; public String CarMaker { get { return _CarMaker;} set { _CarMaker = value; } } p...

C# Help: Sorting a List of Objects in C#

Possible Duplicates: Sort objects using predefined list of sorted values C# Help: Sorting a List of Objects in C# Double Post http://stackoverflow.com/questions/925471/c-help-sorting-a-list-of-objects-in-c/925477#925477 public class CarSpecs { public CarSpecs() { } private String _CarName; publi...

How do you write a class in Javascript?

Possible Duplicate: What's the best way to define a class in javascript How do you write a class in Javascript? Is it even possible? ...

Python Class Inheritance issue

I'm playing with Python Class inheritance and ran into a problem where the inherited __init__ is not being executed if called from the sub-class (code below) the result I get from Active Python is: >>> start Tom Sneed Sue Ann Traceback (most recent call last): File "C:\Python26\Lib\site-packages\pythonwin\pywin\framework\scriptutils...

Static classes...is it OK to do this?

I read When to Use Static Classes in C# but the top answer didn't necessarily answer my question. I've an application that interfaces with quite a bit of similar hardware, via an HTTP server. Each device must be logged into and the credentials are normally the same. I'm using Properties.Settings.Default.etc to handle application wide set...

Determining what classes are defined in a PHP Class file

Given that each php file in our project contains a single class definition... any suggestions for determining what class was defined within the file? I know I could just regex the file for class statements, but I'd prefer to do something that's more efficient. Suggestions? Thanks ...

Abstract vs Normal class inheritance performance

When you derive from a class and instance the subclass, the runtime also instances the super class, right? Since abstract classes can't be instanced, are they not created by the runtime when a subclass is instanced? If so, then abstract class inheritance would be faster than normal class instance? ...

Exploring Implements/Extends in MooTools

I'm working on some effects and things to get a handle on Classes/Implements/Extends. The examples here are for the base classes (MooSlidesFx, MooSlidesFx.Elements) from which to create many effects with a project I'm working on, and two child class (MooSlidesFx.Fade, MooSlidesEffects.Elements.Fade) that actually do something. http://pa...

move data from progress event to another class

in Flex if i have a loader class (i.e., XMLLoader) and a document class (document.as) and in document.as I'm instantiating XMLLoader var ldr:XMLLoader = new XMLLoader(url); ... and on the document.as class I have a text box, which I would like updated with the progress from that XMLLoader is making by using URLLoaders progress event, ...

Resolve IDE warning with generics, Class<?> type

class Test1<T> { Test1(Class<T> type) {} } class Test2 extends Test1<Class> { Test2() { super(Class.class); } } This works, but, I am warned about use of a raw generic type in "Test1<Class>". I understand that, but, changing it to "Class<?>" (which should be equivalent?) gives a compiler error in the call to super() -- Class...

Global settings passed to instance or referenced directly.

I have a Logging class which gets instantiated on startup of a console app and the stored in a static variable. If i want a class to use the logger should it be passed to the class in the constructor or referenced directly? I'm trying to write unit tests and either way i should be able to do it. Just means i have to set the static vari...

Java Method with Enforced Array Size Parameters?

I would like to create an initialisation method for a Java class that accepts 3 parameters: Employee[] method( String[] employeeNames, Integer[] employeeAges, float[] employeeSalaries ) { Employee myEmployees[] = new Employee[SIZE];// dont know what size is for ( int count = 0; count < SIZE; count++) { myEmployees[c...

Cast a class instance to a subclass

I'm using boto to manage some EC2 instances. It provides an Instance class. I'd like to subclass it to meet my particular needs. Since boto provides a query interface to get your instances, I need something to convert between classes. This solution seems to work, but changing the class attribute seems dodgy. Is there a better way? from ...

How do you determine the size of an object in C++

For example, say I have a class Temp: class Temp { public: int function1(int foo) { return 1; } void function2(int bar) { foobar = bar; } private: int foobar; }; When I create an object of class Temp, how would I calculate how much space it needs, and how is it represented in memory (e.g.| 4 bytes for foobar| 8 bytes for function1 | ...