class

php __autoload() and dynamic / runtime class definition - is there a way without eval?

Hi, I read this post after doing a search for related posts. I have a slightly different, but related problem. Is there a way WITHOUT EVAL() (because this is a bad idea - open for abuse if someone allows a user to supply the value that is used in eval, etc) such that you can define the structure of the class, for example: if(!class_e...

Invalid use of class in C++?

hi im trying to pass some values to a class but it wont let me it says invalid use of class 'Figure' im trying to send 3 values x,y,z and thats all but it wont let me heres what im trying to do... here is the main.cpp and the function that calls the class Figure for (j = 0; j < num_elems; j++) { /* grab and element from the file ...

Dependent Classes in Java

For our assignment we need to write code for a neural network. The way I planned to do it was to write a Node class, which is a node within the network; a Layer class, which is a layer of nodes and a NeuralNet class, which is a network of layers. I'm having a lot of trouble understanding the way Java is designed to work for imports. To ...

Using function pointer member variables within an Objective-C Class

Hi, (New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class and a number of its member variables will be function pointers. These function pointers will only be modified by the class itself, but may be used by other classes. I'm not sure how to set up access to said function pointers. The solution I cur...

Using multiple wcf services, factory class to return proxyclient

I have multiple services in my application. WebService1, WebService2,WebService3 and so on.. All the services have same methods, but they are hosted on different IPs. Now when a client calls a methodA(1) then WebService1Client.Method() should be called; client calls a methodA(2) then WebService2Client.Method() should be called. I do...

Overriding a parent class's methods.

Something that I see people doing all the time is: class Man(object): def say_hi(self): print('Hello, World.') class ExcitingMan(Man): def say_hi(self): print('Wow!') super(ExcitingMan, self).say_hi() # Calling the parent version once done with custom stuff. Something that I never see peop...

Determining available operators at runtime

I would like to be able to retrieve the available operators for an object at runtime, possibly in a similar way as the getMethod() call. In particular, I need to be able to call the less-than/greater-than operators of an object at runtime. Basically, I have a bunch of primitives that have been cast to the Object object-type. I need to...

Why would you ever want a Java file with no public classes declared in it?

There is a statement in the book I'm reading for the SCJP qualification, it says : Files with no public classes have no naming restrictions That has made me ask, why would you ever want to do this? If there are no public classes, then how could other classes ever import and use the file? The only purpose I can see is if the fil...

How to have different taxes applied to a configurable product in Magento (Depending on selected options)?

I have product (say a bottle of wine). I can sell it as an in bond item (no tax) or a duty item (attracts duty and VAT tax). How then can I apply this to a configurable product? I have set the tax class of duty simple product to a 'Taxable' product class. The in bond version has been set to 'None'. I have also setup the tax rule, whi...

Is this some kind of referencing problem? Value not sticking

Apologies for the appalling title. I have mocked up this code to mimic an issue I was encountering on a project. I want to know why the property status does not 'stick'. Stepping through the code I can even see it setting the property! Is it something to do with Structure being a value type? Here is the code, it is standalone. Impor...

decorator inside class & decorated classmethod without 'self' gives strange results

Example code: # -*- coding: utf-8 -*- from functools import wraps class MyClass(object): def __init__(self): pass #decorator inside class def call(f): @wraps(f) def wrapper(*args): print 'Wrapper: ', args return wrapper #decorated 'method' without self @call def myfunc(a): pass c = MyClass() c....

Why is there no call to the constructor?

This code doesn't behave how I expect it to. #include<iostream> using namespace std; class Class { Class() { cout<<"default constructor called"; } ~Class() { cout<<"destrutor called"; } }; int main() { Class object(); } I expected the output 'default constructor called', but I did not...

Is there a standard Cyclic Integer Class in C++?

I have a problem that is quite common in the code that I am writing at the moment whereby I want to have an integer that can only exist inside a certain range where the range is [start, end). Basically I want to be able to do something like the following: cyclic_int ci(4, 8); ci = 4; assert(ci == 4); ci += 3; assert(ci == 7); ci += 2; ...

Extending a database class

I have a database: class dbConnect { var $strHost = ""; var $strDatabase = ""; var $strUser = ""; var $strPassword = ""; var $intLinkID = 0; var $intQueryID = 0; var $arrRecord = array(); var $intRow; var $intErrno = 0; var $strError = ""; function dbConnect() { $this->Connect(); } function dbHalt($s...

Is it possible to dynamic_cast from one base class to another?

For instance I have code like that class Base1 { virtual void wonderFULL() = 0; }; class Base2 { // all this weird members }; class Derived : public Base1, public Base2 { // not so weird members }; int main() { Derived Wonder; magicFunction(&Wonder); return 0; } void magicFunction(Base2 *ptr) { if (Base1 *b1 = dynamic_...

Scoping issues in javascript classes

The classical programmer in me is in love with the public/private paradigm of OO and I am finding it very hard to give up. This has caused me to run into an issue I was hoping you can help me with. I have a singleton object called map. There can be only one. This map contains objects called Star (it's a game). A Star looks like this: ...

How can I instantiate a class using the shorthand C# way?

This is the class I'm trying to instantiate: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { public class Posicion { public int X { get; set; } public int Y { get; set; } } } And here I'm trying to create it: button1.Tag = new Posicion() { 1, 1 }; I...

if using an interface should a class always strictly implement an interface

The better way to ask this question would be an example as follows What are the pros and cons of the 2 approaches? Is one always better than the other or under specific circumstances? If using Approach1, using an interface would be moot right? since anyone can access the public methods anyway? public interface IDoSomething { void Meth...

Increment a Integer's int value?

How do I increment a Integer's value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i). playerID.intValue()++; does not seem to work. Note: PlayerID is a Integer that has been created with: Integer playerID = new Integer(1); ...

Tornado Request Handler

For some reason i am unable to instantiate the set_cookie outside of the MainHandler.. This is a little code to show what im wanting to do.. Can Anyone help?? import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web from tornado.options import define, options from GenCookie import * class MainHandler(t...