class

PHP: Instantiate class by reference?

I'm converting some old PHP 4.x code for PHP 5.3. I've come across the following, and I'm not sure what it does. $variable =& new ClassName(); What is the difference between that, and: $variable = new ClassName(); ...

How to get name of the constant?

Assuming you have a constant defined in a class: class Foo { const ERR_SOME_CONST = 6001; function bar() { $x = 6001; // need to get 'ERR_SOME_CONST' } } Is it possible with PHP? ...

Swap a class of an <li> on click

I am trying to swap the selected class from tab to tab to display which one is current Sample Code $("li.selected").idTabs(function(id,list,set){ $("a",set).removeClass("selected") .filter("[@href='"+id+"']",set).addClass("selected"); for(i in list) $(list[i]).hide(); $(id).fadeIn(); return false; }); so on click I am trying...

jquery - count divs with ids in an array?

Not sure how to do this with jquery, but I'm trying to return a count of the number of divs that have specific classes... <div id="main"> <div class="contact">Data</div> <div class="margin">Margin</div> <div class="contact">Data</div> <div class="break">Break</div> <div class="break">Breaker</div> <div class="nap">Nap</div> </div> A...

Dynamically add a servlet to the servletConfig

Hi All I have a Java web application that uses a plugin architecture. I would like to know if anyone has a solution where by one could add a servlet, with serlvet mapping to the servletconfig while the web app is running? The idea being that a class could be added to the /WEB-INF/classes folder and be made active as a servlet without re...

Iterating through the Object Browser in VBA

I would like to iterate through members of any class in a referenced library much like is done using the Object Browser. How can this be done using VBA? ...

c classes functions

Ok this may be a silly question for many of you. Let me preface this with a list in order of the languages I've learned over the past 10 years. [by the way, I understand that some of these are scripting languages] vb 6.0 html asp php css javascript managed c++ c# c++ C ASM Yeah I know I started at the complete opposite end, but hopef...

Dynamically converting java object of Object class to a given class when class name is known

Yeah, I know. Long title of question... So I have class name in string. I'm dynamically creating object of that class in this way: String className = "com.package.MyClass"; Class c = Class.forName(className); Object obj = c.newInstance(); How I can dynamically convert that obj to MyClass object? I can't write this way: MyClass m...

How to make the Color class helper?

Hi. I am trying to make a class helper for the Color class in C#. I am a Delphi programmer and as far as I know, class helpers allow you to expand base classes so when you create an instance of the base class, you have access not only to the base methods, but also to all those defined in the helper class. Is it possible to achieve a simi...

abstract class and using array polymorphically

i'm just reading meyers "More Effective C++ 35 New Ways" - item 33, and he suggest there always to inherit from an abstract base class, and not a concrete. one of the reason he claims, which i can't quite get , is that with inheriting from an abstract class, treating array polymorphically (item 3 in the book) is not a problem. can some...

jQuery: Get ids from class

Hi, I have a lot of div's and I want to fade this one who is hovered. How i can get the id of the hovered div? Is there anyway to do that except calling function(and sendind the id) with "onmouseover"? Thanks! ...

Histogram frequency help Java

public class Histogram { private int lo_; private int hi_; private int[] frequency_; public Histogram(int lo, int hi) { lo_ = lo; hi_ = hi; int range = hi_-lo_+1; frequency_ = new int[range]; for(int i =0; i <range; range++) frequency_[i] = 0; } public void ReadValue() { Scanner in = new Scanner(System.i...

Javascript 2.0 classes

I'm reading a book "How to Do Everything with JavaScript" and I'm currently learning how to define classes. The book says there are 2 ways. first using functions in javascript 1.x. second, using class in javascript 2.0. what I'm trying is: class Car { var Make : String; var Model : String; var Year : Integer; var Color : String; var Fu...

Haskell record syntax and type classes

Suppose that I have two data types Foo and Bar. Foo has fields x and y. Bar has fields x and z. I want to be able to write a function that takes either a Foo or a Bar as a parameter, extracts the x value, performs some calculation on it, and then returns a new Foo or Bar with the x value set accordingly. Here is one approach: class ...

Change UIImagePickerController Delegate

I access the camera via UIImagePickerController, and when I set the delegate to self, I can use the delegate methods. However, for what I have planned I need to have the delegate methods in another class, but whenever I try to do that, it will dismiss the the picker whenever I take a picture. When I do this, it works: preview.delegate...

(In Ruby) allowing mixed-in class methods access to class constants

Hi. I have a class with a constant defined for it. I then have a class method defined that accesses that class constant. This works fine. An example: #! /usr/bin/env ruby class NonInstantiableClass Const = "hello, world!" class << self def shout_my_constant puts Const.upcase end end ...

PHP[OOP] - How to call class constructor manually?

Please see the code bellow: 01. class Test { 02. public function __construct($param1, $param2, $param3) { 03. echo $param1.$param2.$param3; 04. } 05. } 06. 07. $params = array('p1','p2','p3'); 08. 09. $ob = new Test; 10. 11. if(method_exists($ob,'__construct')) { 12. call_user_func_array(array($ob,'__construct'),$...

Standalone functions in ASP.net

Never seen this done in asp.net, but never the less, can I define functions without being part of the class? What I would like to have is a utility library. Currently I have Utils class and every time I need to use it for things like populating drop down lists i have to create and init the Utils() object...any way around that hassle as...

Flash AS3 - Objects of same base class in library - Type coercion failed

This happens to me a lot and I've yet to find a good solution. Say you have two classes, Tree (com.company.Tree) and Fruit (com.company.Fruit). On the stage in Flash, the Tree has an instance of Fruit (class=fruit1, base class=com.company.Fruit), and it's instance name is fruit. Everything is fine, until you duplicate the tree and fruit ...

Adding css class through aspx code behind

I am using aspx. If I have HTML as follows: <div id="classMe"></div> I am hoping to dynamically add a css class through the code behind file, ie on Page_Load. Is it possible? Thanks coders. ...