class

How to code inlineable mutual abstracion in C++ ?

Example first: template <class HashingSolution> struct State : public HashingSolution { void Update(int idx, int val) { UpdateHash(idx, val); } int GetState(int idx) { return ...; } }; struct DummyHashingSolution { void UpdateHash(int idx, int val) {} void RecalcHash() {} }; struct MyHashingSolution { void Upd...

Member pointer to array element

It's possible to define a pointer to a member and using this later on: struct foo { int a; int b[2]; }; int main() { foo bar; int foo::* aptr=&foo::a; bar.a=1; std::cout << bar.*aptr << std::endl; } Now I need to have a pointer to a specific element of an array, so normally I'd write int foo::* bptr=&(foo::b[0]); However, ...

Are static inner classes a good idea or poor design?

I'm find I have several places that having public static inner classes designed that extend "helper" classes makes my code a lot more type safe and, in my opinion, readable. For example, imagine I have a "SearchCriteria" class. There are a lot of commonalities for the different things I search for (a search term and then a group of searc...

How can I access a class variable via an array in VB.NET?

If I have the following class and declaration: Public Class objLocation Public SysLocationId As String Public NameFull As String Public LatRaw As String Public LongRaw As String Public Active As Integer End Class dim lLocation as new objLocation I can access each variable thus lLocation.SysLocationId, etc. Is there an ...

python class __getitem__ negative index handling

Is there a common function to do this? Right now I'm just doing the following (and overriding __len__) idx < 0: idx = len(self) + idx if idx < 0 or idx >= len(self): raise IndexError, "array index (%d) out of range [0, %d)" %(idx, len(self)) ...

Subclassed Textbox readonly font not recognized on form

Building my baseclasses for user interface controls is getting there. I have command buttons derived with custom font assignment and put on a form, all is fine... However, identical code for the read-only property Font of a textbox is NOT recognized properly on the same form. It is ONLY taking the setting of the FORM and disregarding i...

Intercepting changes of attributes in classes within a class - Python

I have been messing around with pygame and python and I want to be able to call a function when an attribute of my class has changed. My current solution being: class ExampleClass(parentClass): def __init__(self): self.rect = pygame.rect.Rect(0,0,100,100) def __setattr__(self, name, value): parentClass.__setattr__(sel...

Get a class from my flash library dynamically

I have several bitmaps in my flash library that I have exported for Actionscript. Now depending on the Flashvars I receive I want to load the corresponding library bitmap. How do I load a bitmap class dynamically? ...

Class declared inside of another class in C#

I am working on some legacy code and have come across something that I'm not sure of. We have a class y that is declared inside of another class x. Class y is only ever used inside of class x but my question is why wouldn't you create a separate class file and put class y in there instead of declaring it inside of class x? Isn't this vio...

What are the fundamental differences between Java and C# in terms of inner/local/anonymous classes?

What are the fundamental differences between Java and C# in terms of inner/local/anonymous classes? ...

AS3 class for a Flash Symbol

Hi, I am new to Flash, I am trying to create a class for a symbol. I created a new Flash file, drop a DynamicText, convert this DynamicText to a Symbol called "TextBox1" Then I created TextBox1.as in the same directory as the .fla I just created. package { import flash.display.*; public class TextBox1 extends MovieClip { public...

PHP4 session / object problem

I have a weird problem with PHP4 I have a class which assigns a $_SESSION variable. On the local dev server it works as: $_SESSION['foo'] = $this->foo; and I can access $_SESSION['foo'] as a string. on the live server $_SESSION['foo'] is not a string but a serialized object? the same code? ...

How is the lifetime of a static class affected in a stateless asp.net application?

I've defined a helper class to keep track of a small dictionary of items. it stores this information as a static property, which is initialized in the static constructor. the list is very small and will never change so I chose this method over xml or a db lookup table... however what I would like to know is, will this static property re...

Calling a Class in ASP.NET

Hi I know my ASP.NET but i have to admit, i am dumb with classes and not sure how they work exactly. Also have not worked with them yet but i want to. But what I do know is that it's a place where i can keep code for re-use correct? How will my class look with my code? So this is my code i use on about 3 forms - but i want to save it i...

How do you create multiple instances of a library class in CodeIgniter?

I'd like to create several instances of a class in codeigniter. I have created my class as a library, but cannot figure out the syntax to use to create more than 1 instance. ...

PHP: How to initialize static variables

I have this code: private static $dates = array( 'start' => mktime( 0, 0, 0, 7, 30, 2009), // Start date 'end' => mktime( 0, 0, 0, 8, 2, 2009), // End date 'close' => mktime(23, 59, 59, 7, 20, 2009), // Date when registration closes 'early' => mktime( 0, 0, 0, 3, 19, 2009), // Date when early bird discount ends ...

Understanding Python Class instances

I'm working on a problem which uses a python class and has a constructor function to give the number of sides to one die and a function to roll the die with a random number returned based on the number of sides. I realize the code is very basic, but I'm having troubles understanding how to sum up the total of three rolled dice with diffe...

Rails Reserved Class Names

I tried creating a model called "class" (as in a graduating class of students), and encountered all kinds of problems. What are some other words or class names to avoid in Rails? Some links I've found: http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/ http://railsforum.com/viewtopic.php?id=22242 ...

Class method can't access properties

I have created a class like so: function MyClass() { var myInt = 1; } MyClass.prototype.EventHandler = function(e) { alert(this.myInt); } Unfortunately, the this is the triggered event (in my casss an tag), and i can't access the class properties. Any suggestions? ...

How do I get the filepath for a class in Python?

Given a class C in Python, how can I determine which file the class was defined in? I need something that can work from either the class C, or from an instance off C. The reason I am doing this, is because I am generally a fan off putting files that belong together in the same folder. I want to create a class that uses a Django template...