class

Is it always evil to have a struct with methods?

I've just been browsing and spotted the following... http://stackoverflow.com/questions/54585/when-should-you-use-a-class-vs-a-struct-in-c The consensus there is that, by convention, you should only use struct for POD, no methods, etc. I've always felt that some types were naturally structs rather than classes, yet could still have a ...

is there a difference between class(): and class(object): in python 2.6-3.x?

Before py2.6 it's been answered here. http://stackoverflow.com/questions/332255/difference-between-class-foo-and-class-fooobject-in-python But for python2.6+ and python3.x, is the first one wrong? class Foo(): pass vs class Foo(object): pass ...

Can we draw sequence diagrams if we don't have classes in a program?

I have a program I made in C++ that does not use classes, just simply functions and main(). I want to know what kind of diagrams I can draw for it. Here are a couple of things I have in mind. Activity diagram Sequence diagram class diagram - obviously can't draw this because I didn't use classes system architecture state diagrams use ...

Find info about class in java, software design?

I have a bunch of classes extending an abstract Base class. Each subclass takes an array as in the constructor, (different length depending on class). These classes could be written by other people. What is the best way to figure out the length of the array the class needs? I could: (A) Require that each derived class have a static meth...

Tiny crashing program

The following program compiles with g++ but then crashes upon running: class someClass { public: int const mem; someClass(int arg):mem(arg){} }; int main() { int arg = 0; someClass ob(arg); float* sample; *sample = (float)1; return 0; } The following program does not crash: int main() { float* samp...

How have you dealt with the lack of constructors in VB6?

VB6 class modules have no parameterized constructors. What solution have you chosen for this? Using facory methods seems like the obvious choice, but surprise me! ...

Passing a Class object to a function in Objective C - with restrictions on the classes that it represents?

(I probably didn't phrase that very well!) I'd like to pass a Class object into an Objective C function: -(void)someMethod:(Class *)classObject { ... And, if I want to restrict the parameter to classes who implement a particular protocol, I know I can do this: -(void)someMethod:(Class<SomeProtocol> *)classObject { ... But is it po...

class object in class with php oop

I am not even sure how to ask. I do this all the time in C# but for the life of me I cannot find any decent examples in PHP. Can you help? What I am trying to do is for example. Say I have a class called Company who has many Employees. I want to be able to store all the employees in the company class then later when I iterate throug...

Deriving class from `object` in python

So I'm just learning python (I know plenty of other languages) and I'm confused about something. I think this is due to lack of documentation (at least that I could find). On a few websites, I've read that you should derive your classes from object: class Base(object): pass But I don't see what that does or why or when you shou...

PHP: How to loop through a dynamic number of classes

I'm wanting to detect all objects(classes) defined in a php file (example: flavors.php). The number of objects will be defined dynamically, so I need to process the available objects with a function at runtime until the objects are exhausted. After the objects are exhausted the program stops. I have full control over the code, so if the...

iphone EXC_BAD_ACCESS using my own class

Hi all! I made my own class derived by NSObject, and here is my code: -(void) parseRow:(NSDictionary*) dictionary { NSArray* arName = [[dictionary valueForKey:displayname] componentsSeparatedByString:@"+"]; [self setDriverName:[arName objectAtIndex:0]]; [self setDriverSurname:[arName objectAtIndex:1]]; [arName release]; ...

How to get the class that created the current object?

I would like to prevent foo() from being executed by any other class than B. How can I check which class created object A? <?php class A { public function foo() { if (.... B ) // what should be on the dotts? echo 'I\'m created by class B, which is fine'; else echo 'Execution of foo() is n...

C# Rendering 'player' sprite from differend class

Hello, i was wondering how could i display 'player' sprite from Player.cs class. So far everything was happening in Program.cs file, witch had 'device' for rendering. Now i want to do same but using different classes. Do i need to create device for each class to render stuff thats happening within them, or i need to somehow access the de...

PHP: Get method's arguments?

In php I can check all available methods for an object like so: $methods = get_class_methods($object); But how can I see wich arguments have to be sent to these methods? Is there a function for this? ...

Can eclipse convert/refactor a method to a class?

This seems like it should be fairly straight-forward, but I can't see anything obvious. What I basically want to do it to point at a method and refactor->extract class. This would take the method in question to a new class with that method as top level public API. The refactoring would also drag any required methods and variables alon...

Need an example of how to use class -> SingleLaunchActivityTestCase<T extends Activity>

Hi All I am quite new to Android and Java I am looking for example of how to use this class: SingleLaunchActivityTestCase Till now I am using class InstrumentationTestCase but the problem is that for each launched test case Android calling onSetup() and TearDown() Need help urgently ...

How to set up a class two steps down?

I'm getting a little confused how to set up a class that's two steps below the top-most one. For instance, say I have a game called BoardGame. One of whose parameters in numberOfSquares. The classes are setup like this: BoardGameSetupViewController > BoardGamePlayViewController > GameEngine BoardGameSetupViewController creates an ins...

Class method does not invoke on iPhone

Hi, I wrote a small class containing 2 class methods for some calculations. I call those methods from another class. I have declared everything properly in both classes and Xcode does not give any warnings. Still, I checked with debugger and when I call method from this class it just doesn't invoke THis is declaration: +(double)Double...

Creating a CSS class in jQuery

I believe the .addClass() function in jQuery attaches a CSS class to the current selection, but I was wondering I could create or define a CSS class in jQuery, and then attach it? ...

How To Pass HashMap Records Into JSP?

Im new to using HashMap. Im assigned a project to retrieve records from HashMap and display it as a Pie Chart on a JSP. However despite searching and look thru many different Hashmap examples. Im still stuck in my project which is about to due in 3 weeks time :( Kindly please give me some advice and i apologize if my code is in a mess. ...