class

howto let ruby share data beetwen a class and its subclasses in conjuction with extend

module M def f=(x) @f= x end def f @f end end class A extend M end class B < A end A.f= 42 puts A.f puts B.f this produces 42 nil Is @f a class variable to A and B? How do I share a variable between A and B by only writing this into M? ...

How do I get intellisense(code insight) features like of Jcreator in an IDE of linux platform ?

I previously programmed a lot in JCreator, but since I moved to ubuntu. I miss my Jcreator more than anything. Beside Eclipse or Netbeans, are there some lightweight software that does my task. Tried already gedit, jedit, scite, geany etc. with APIs plugins. But I can't find anything like Jcreator ? I just have 256 MB SDRAM to spare in ...

Creating an array of zero width and zero height!?

I have an assignment from my programming class, which is very poorly worded... The following line really stumps me. We're creating a class called FloatArray, which contains an array (arr, which is just a pointer to a bunch of floats). The default constructor FloatArray(); should create array of zero width and zero height. I have ...

C# class design without using "Internal" or "Static"?

I have a bunch of data I want to instantiate in a class, and for each variable I want to ensure a specific set of methods are also defined. IE: [TypeA] VarA [TypeB] VarB [TypeC] VarC FA1() which is a function of VarA and VarB FA2() which is a function of VarA and VarC FB1() which is a function of VarB and VarA FB2() which is a functio...

Dynamic Child Class generation - PHP

I have an abstract "object" class that provides basic CRUD functionality along with validation, etc. Typically I would use the __autoload($name) magic function to load a class that would exist in its own file, named the same as the class I wish to lazy load. The code would look something like this, which as you can imagine becomes quit...

Flash AS3: Unable to view loaded swf after loading it inside of package

Good morning friendly Flashers ;) So I've been trying since yesterday to just load a SWF file into my main movie. I've done this before just placing code inside a movieClip, but this time I'm working inside of Class files. I have my main class which calls a function inside of my sub class which contains the loader. My problem is that the...

Properly disposing of class with thread

I have a fairly complex multi-threaded Windows service working, but I can't figure out how to clean up correctly. Below is some [pseudo] code to show what I have. The actual code is much more complex, probably too much to copy/paste here. Basically, I have a class Request that creates a thread to do the work. When a new request comes...

PHP Class Scope issues

Below is a very basic example of the trouble I am having. Now why must I use $session = new Session(); in the database.class.php file when in my system the files are included in a way that it would be visible already. In other words I cannot call $session = new Session(); outside of any other classes, to make it work in other classes...

How can I initiate a PHP class and use it in several files?

I am stumped right now. In my last post about this question the answer was to use a singleton to make sure an object is only initiated 1 time but I am having the opposite problem. If I have a file called index.php and then I include these files into it, class1.php, class2.php, class3.php, class4.php. In index.php I will have, <?PH...

singleton inside of a construct method in PHP?

Is it ok to use a singleton method inside of a __constructor to initiate the class if it wasn't already? ...

Can I declare something global at the class level in PHP?

Is there a way to set something as global in a class and have all methods of that class to have access to it? Currently if I use global $session; I have to add it into every method that uses it even if all the methods are in the same class. If I try to add it directly into the class then I get a php error saying it is expecting a funct...

Which classes do I need to nice solve the problem?

Hi, I'm new to object oriented php, so I'm not sure which classes do I need for programming. I want to write little program, to show information from the database. There is a web page with the form for user input above and some space for the database output. User can enter something and programm logic will query the database and make so...

How to make Class.forName ignore lowercase/uppercase

For example when I have a class named; 'MonkeyBusiness' I know I can call it using Class.forName("MonkeyBusiness"); But when I call it using Class.forName("monkeyBusiness"); or Class.forName("monkeybusiness"); it gives me the exception; Exception in thread "main" java.lang.NoClassDefFoundError: monkeyBusiness (wrong name: ntx/gmd/se...

Java Scanner class reading strings

I got the following code: int nnames; String names[]; System.out.print("How many names are you going to save: "); Scanner in = new Scanner(System.in); nnames = in.nextInt(); names = new String[nnames]; for (int i = 0; i < names.length; i++){ System.out.print("Type a name: "); names[i] = in.next(); } System.out.printl...

Designing a Vector3D class

Hi all I dont know which is the best practice when we want to create a new vector 3D class, i mean, which of this two examples is the best way ? class Vec3D { private: float m_fX; float m_fY; float m_fZ; ... }; or class Vec3D { private: float m_vVec[3]; ... }; With the first aproach, we...

Call a class inside another class in PHP

Hey there I'm wondering how this is done as when I try the following code inside a function of a class it produces some php error which I can't catch public $tasks; $this->tasks = new tasks($this); $this->tasks->test(); I don't know why the initiation of the class requires $this as a parameter either :S thanks class admin { func...

How can I use variables set in a PHP class?

In this little example below in PHP what would be a good way to be able to create the variables in the user class and then be able to use them on any page where I create a user object? <?PHP //user.class.php file class User { function __construct() { global $session; if($session->get('auto_id') != ''){ //set u...

Better to use an Object or a Static Function in PHP?

I am trying to learn OO and classes and all that good stuff in PHP, I am finally learning the sytax good enough to use it some and I am curious if there is any benefit of starting a new object instead of just using static methods...let me show some code for what I mean... <?PHP test class { public function cool() { re...

Add class to jquery dialog buttons

Hi there, I want to add css class on buttons of a jquery dialog box. Here is my code : $(document).ready(function(){ $('#messageBox p').html('bla bla bla. Ok?'); $('#messageBox').dialog({ modal : true, buttons: { 'Yes': function() { doSomething(); $(this).dialog('close'); }, ...

Where do you get your PHP documentation from?

Most IDEs come with complete documentation that can be installed locally, but I have a particular problem with PHP, as even the Netbeans PHP IDE links to online docs. How do you manage yours? Is there a hidden downloadable docs for PHP somewhere? ...