class

Can i pass class method as and a default argument to another class method

i want to to pass class method as and a default argument to another class method, so that i can re-use the method as a @classmethod @classmethod class foo: def func1(self,x): do somthing; def func2(self, aFunc = self.func1): # make some a call to afunc afunc(4) this why when the method func2 is called within the class aFunc de...

Looping class, for template engine kind of thing

Hey, I am updating my class Nesty so it's infinite but I'm having a little trouble.... Here is the class: <?php Class Nesty { // Class Variables private $text; private $data = array(); private $loops = 0; private $maxLoops = 0; public function __construct($text,$data = array(),$maxLoops = 5) { // S...

testing existing attribute of a @classmethod function, yields AttributeError

i have a function which is a class method, and i want to test a attribute of the class which may or may not be None, but will exist always. class classA(): def __init__(self, var1, var2 = None): self.attribute1 = var1 self.attribute2 = var2 @classmethod def func(self,x): if self.attribute2 is None: do something i get th...

C++ HW - defining classes - objects that have objects of other class problem in header file (out of scope?), (also redefining operators, read in out)

This is my first time with much of this code. With this instancepool.h file below I get errors saying I can't use vector (line 14) or have instance& as a return type (line 20). It seems it can't use the instance objects despite the fact that I have included them. #ifndef _INSTANCEPOOL_H #define _INSTANCEPOOL_H #include "instance.h" #inc...

C# Strange Behavior

I have a custom struct : struct A { public int y; } a custom class with empty constuctor: class B { public A a; public B() { } } and here is the main: static void Main(string[] args) { B b = new B(); b.a.y = 5;//No runtime errors! Console.WriteLine(b.a.y); } When I run the above program, it does ...

F# Class with Generics : 'constructor deprecated' error

I am trying to create a a class that will store a time series of data - organized by groups, but I had some compile errors so I stripped down to the basics (just a simple instantiation) and still can't overcome the compile error. I was hoping some one may have seen this issue before. Clas is defined as: type TimeSeriesQueue<'V, 'K whe...

need help ,php class and xml save load edit example.p

http://www.sendspace.com/file/2zlfgn I have the php files i been trying to get them to save to xml. I have tried $product1=array(); $product1['id'] = new product( "19990","modrl","maf","purpose","war"); only the ID writes to xml. since model, maf etc are sub-elements is there a different way to create the object array? ...

How to easily substitute a Base class

Hi, I have the following hierarchy of classes class classOne { virtual void abstractMethod() = 0; }; class classTwo : public classOne { }; class classThree : public classTwo { }; All classOne, classTwo and classThree are abstract classes, and I have another class that is defining the pure virtual methods class classNonAbstra...

Generic collection class?

Is there anyway I can do this? class TSOC<TCollection, TValue> : ICollection<TValue>, INotifyCollectionChanged where TCollection : ICollection { private TCollection<TValue> collection; } It doesn't like my definition of collection. I'd prefer the definition to look like TSOC<TCollection> where the user can pass in List<int> or som...

Actionscript package naming and directory structure

Hello all, I've got some actionscript which begins with: package obfus_plugin{ import org.flowplayer.model.Plugin; import org.flowplayer.util.Arrange; import org.flowplayer.model.PluginModel; import org.flowplayer.view.Flowplayer; public class obfus extends Sprite implements Plugin { and when I try to p...

Python using methods from other classes

If I have two classes, and one of them has a function that I want to use in my other class, what do I use so that I don't have to rewrite my function? ...

Generic Aggregation of C++ Objects by Attribute When Attribute Name is Unknown at Runtime

I'm currently implementing a system with a number of class's representing objects such as client, business, product etc. Standard business logic. As one might expect each class has a number of standard attributes. I have a long list of essentially identical requirements such as: the ability to retrieve all business' whose industry is...

Use Struct as a Ptr/class? Need a fix .NET

I wrote a bunch of code and i would like to fix it the fastest way possible. I'll describe my problem in a easier way. I have apples and oranges, they are both Point and in the list apples, oranges. I create a PictureBox and draw the apple/oranges on screen and move them around and update the Point via Tag. The problem now is since its...

Event Triggering in asp.net using javascript

i have created two buttons using html. yes and No. i need the get the event triggered when the button is clicked i.e... onclick=getvalue(). public void SetYesButton(string msg_button_class) { this.msgbox_Yes_button = "<input type=\"button\" value=\"Yes\" class=\"" + msg_button_class + "\" onClick=\"getvalue()\";>"; } public...

In Ruby, how to implement "20 - point" and "point - 20" using coerce() ?

In Ruby, the operation of point - 20 # treating it as point - (20,20) 20 - point # treating it as (20,20) - point are to be implemented. But the following code: class Point attr_accessor :x, :y def initialize(x,y) @x, @y = x, y end def -(q) if (q.is_a? Fixnum) return Point.new(@x - q, @y - q) end Poin...

Simple OOP-related question.

This question came to my mind quite a few times. Let my explain my question through an example. Say I've got two classes: 1- Grid. 2- Cell. Now the location of the cell 'should' be stored in the grid class, not in the cell class itself. Say that the cell wanted to get its location through a method in the grid. How can it do that? Kee...

filter divs by class - jquery

Hi, there are several list filters in jquery (quicksand, filterprojects, etc.), but I am looking to filter divs by class. I want the same functionality of the above - you select a menu item attached to a class and the other items fade out. Anyone seen anything like this anywhere? ...

C++ Beginner - Trouble using classes inside of classes

Hello, I am working on a college project, where I have to implement a simple Scrabble game. I have a player class (containing a Score and the player's hand, in the form of a std::string, and a score class (containing a name and numeric (int) score). One of Player's member-functions is Score getScore(), which returns a Score object for...

Getting the error "Unexpected $end" in my class file

I'm writing a php library that handles different products, somewhere in my class I must have a missing curly brace or something but I can't find it. Does someone with a debugger or keen eyes see anything wrong with this code? http://pastie.org/953994 Thanks in advance! Edit: I think it's something with the query in the EquipmentData...

C# OOP File Structure?

Hey SO, I just started programming with objects recently and am trying to learn good habits early on. The way I plan to structure my application is to have two files: 1: Program.cs - This file will contain the main logic for the application 2: Class.cs - This file will contain all of the class definitions Pretty simple. What I'm w...