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 ...
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
...
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 ...
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...
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...
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!
...
(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...
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...
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...
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...
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]; ...
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...
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...
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?
...
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...
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
...
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...
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...
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?
...
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.
...