class

Is there any way to assign to a variable by a Type object in C#?

I have a base class "Element" and derived two other classes from it, "Solid" and "Fluid". class Element {...} class Solid : Element { public const int ElemType = 2; ... } class Fluid : Element { public const int ElemType = 3; ... } I have made an instance of "Element" c...

When java class X required to be placed into a file named X.java?

Guys, I've come across such legal behaviour: File B.java: final class C {} final class D {} File A.java: class B {} public class A {} Questions: When class X is required to be placed into its own X.java file? Does class visibility/final matter here? Is there any official spec on this class/java relation? Thanks a lot. ...

use of upload class in codeigniter - Model or Controller ?

Hi, Quick question about CI. I have a view with a form, several text input fields and a file upload. I want to be able to take the input from the text fields, save it to the DB, and then upload the image. I've achieved this by having the upload code in a controller, and if the upload is successful, a call to my Model is made to update...

using System::Drawing namespace in managed C++ class library

Hi Everyone, I am moving a few functions from a Managed C++ Winforms app to a class library so that I can call them in a new C# app I'm writing. However one of the functions returns a System::Drawing::Bitmap^ and uses the System::Drawing::Color class which is causing an error saying that System does not contain a namespace called Drawin...

Unpickling a Python class

I have a problem trying to unpickle subclasses of this class. When I unpickle it, the stuff isn't there. What gives? class Account: def __init__(self, server, port, smtp_server, smtp_port): self.server = server self.port = port self.smtp_server = smtp_server self.smtp_port = smtp_port sel...

Is it possible to call function from parent class directly in PHP

I have class P { function fun() { echo "P"; } } class Ch { function fun() { echo "Ch"; } } $x = new Ch(); How to call parent function fun from $x? Is it possible to do it directly or I have to write: function callParent { parent::fun(); } ...

Better option for strongly-typed containers in javascript

I've just discovered the way to create fake 'classes' in javascript, but I wonder how you can store them and still get easy access to their functions in an IDE. Like this: function Map(){ this.width = 0; this.height = 0; this.layers = new Layers(); } Now I've got a function that loops through an XML and creates multiple Map(...

How to swizzle a class method on iOS?

Method swizzling works great for instance methods. Now, I need to swizzle a class method. Any idea how to do it? Tried this but it doesn't work: void SwizzleClassMethod(Class c, SEL orig, SEL new) { Method origMethod = class_getClassMethod(c, orig); Method newMethod = class_getClassMethod(c, new); if(class_addMethod(c, orig, method_g...

How to "pass" class attribute to a class method?

How can I "pass" eventName to dbSafe() in the following fashion? Is this possible? What would dbSafe() look like? $eventClass->eventName->dbSafe(); I'm guessing dbSafe() would look roughly like this: public function dbSafe() { return mysql_real_escape_string($this); } ...

how to update a textbox from a static class?

This is driving me nuts. I have a working text based application. It has many many variables which now need a GUI. I'm starting with the basics. Whenever some data is sent to my log, I want it to display in my textbox. Here is a unified entry point for data to pass where it can be manipulated. public class Log { private static...

.Net: Static classes and multithreading?

hi I was told that in multithread programs, we would have some troubles by static classes. Could you please explain it more ? ...

$settings array or Config Class to store project settings?

How should I store settings for project? Which is better - to use a $settings array with all my settings: $settings['max_photos'] = 30; //... or create a singleton Config class with all the settings in it? Class Config { private $max_photos = 30; //... } Any good examples? ...

Getting all classes from the current workspace in Eclipse.

Hi, am writing an Eclipse plugin, and I was trying to create a method that returns all the classes in the workspace in an ArrayList<\Class<\?>> (I added the "\" to include the generic brackets since html won't let me do so otherwise). Here is the code I have: private ArrayList<Class<?>> getAllClasses() throws JavaModelException { Arr...

InitWith Methods vs. Factory Methods

I'm picking up ObjC and Cocoa, which is also my first serious foray into programming in general. I'm having trouble with the differences between initWith methods, which are called on instances, and factory methods, which are called on classes. Firstly, why are they called "factory" methods, and is there a proper term for what I've dubb...

Is there a way to resolve class method dynamically on Objective-C?

I can define and resolve dynamic method without any errors or warnings with @property, @dynamic and -resolveInstanceMethod: However, they're instance methods, but I want to resolve class method dynamically. How can I archive this? ...

[Ruby] How do I access the string name of the parent class from a class method in a extended class or included module.

My problem basically looks like this: module Foo class Bar def self.who self.class.to_s end end end class World < Foo::Bar end When I call World.who I don't get "World" as a result, I get "Class". Some quick Googling didn't yield anything useful, so hence I'm here hoping someone will know how to get the correct cla...

PHP scope between two classes

Hello... I have a few files like below: index.php: require_once("foo.php"); require_once("bar.php"); foo.php: class foo { function1() { } } bar.php: class bar { ????? } My question is, is there any way of accessing function1 from the foo class in the bar class, without having to include the foo.php file in the ba...

Implementing class descriptors by subclassing the `type` class

I'd like to have some data descriptors as part of a class. Meaning that I'd like class attributes to actually be properties, whose access is handled by class methods. It seems that Python doesn't directly support this, but that it can be implemented by subclassing the type class. So adding a property to a subclass of type will cause i...

Modeless Child Dialog

I'm creating modeless child dialogs from a parent dialog class and i want to share the class data of its parent window with all child dialog classes I'll be creating. how would i go do that? ...

How do you make classes in JavaScript?

How do you guys make "classes" in JavaScript!? I am using: function classFoo() { var classLevelVariable = 0; this.classFunction = function() { alert("The classFunction has been called."); classFunction2(); //Crash. classFunction2 is "undefined." } this.classFunction2 = function() { alert("classF...