object

Controlling object creation

I have a class whose object must be created on the heap. Is there any better way of doing this other than this: class A { public: static A* createInstance(); //Allocate using new and return static void deleteInstance(A*); //Free the memory using delete private: //Constructor and destructor are private so that the object can not b...

Dynamic Properties for object instances?

Hi After the previous question "What are the important rules in Object Model Design", now I want to ask this: Is there any way to have dynamic properties for class instances? Suppose that we have this schematic object model: http://www.freeimagehosting.net/>http://www.freeimagehosting.net/uploads/d3a08e6c83.gif border=0 alt="Free Im...

How do you create a method for a custom object in JavaScript?

Is it like... var obj = new Object(); obj.function1 = function(){ //code } or something like that? ...

finding object in Javascript

I have a form with thousands of checkboxes, and when one is checked, I want to check all the boxes below it. This works: <html> <body> <form name="myform"> <input type="checkbox" name="box1" onClick="redrawboxes(this);">1<br> <input type="checkbox" name="box2" onClick="redrawboxes(this);">2<br> ... </form> </body> </html> <script> funct...

object constructor - shorthand property syntax

A few months ago i read about a technique so that if there paramaters you passed in matched the local variables then you could use some short hand syntax to set them. To avoid this: public string Method(p1, p2, p3) { this.p1 = p1; this.p2 = p2; this.p3 = p3; } Any ideas? ...

How to find if an object is from a class but not superclass?

In C# how can you find if an object is an instance of certain class but not any of that class’s superclasses? “is” will return true even if the object is actually from a superclass. ...

Referencing keys in a Javascript object

var foo = { someKey: "someValue" }; var bar = "someKey"; How do I get the value "someValue" using foo and bar? OK, the PHP equivalent: $foo = array("someKey" => "someValue"); $bar = "someKey"; print $foo[$bar]; // someValue So... I'm looking for the JS equivalent for the above, except I don't wanna use a JS array. Help please? ...

How can I call methods on a tied variable?

I've just started to learn about tie. I have a class named Link which I would like to do the following thing: if fetched, return the link's address if stored, store the new address be able to call methods on it So far, my code is : package Link; sub FETCH { my $this = shift; return $this->{"site"}; } sub STORE { my ($...

Best replacement for var flashElements = document.getElementsByTagName("EMBED");

I want to find all flash objects on a random page (to make them wmode=transparent so they wont hide a menu). IE does not support EMBED in: document.getElementsByTagName("EMBED"); Any idea what is the most efficent to find all embeds (no jQuery...) Also for the more advanced: I came across sites where the embed tag was written as eMBE...

Changing arbitrary flash objects wmode to transparent

I need to change wmode of arbitrary flash objects to transparent from external js file to make sure they don't hide menus without using Jquery or similar libs. In FF I use getElementsByTagName("embed") and set attribute. It seems to work well. Specifically I'm having trouble with object set by swfObject library In IE7. swfObject creat...

How can a object self destruct on an event, in javascript?

I have this function, to create a DIV on-the-fly. But now, I want to destroy this object on onclick event, but I just don't know how. function creatediv(id) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.onclick=function(){this=null;}; //bad function document.body.appendChild(newdiv...

Object reference not set to an instance of an object.

I usually get this error and (always) don't know how to solve it. This time I got it also, it seems that I'm not understanding a concept or missing something Here's the code // create a new twitteroo core with provided username/password TwitterooCore core = new TwitterooCore(username, password); // request frien...

Java newbie: inheritance and where to declare an intended universal object

G'day all, I have a Player class, which inherits from an ArmedHumanoids class, which inherits in turn from a Humanoids class. Where and when should I create the Player object so that it is accessible in all my other classes - for example, a selectPlayerRace class? I know that by extending the Player class it becomes accessible, but I...

How to create gradient object with Raphael

Hi, I was trying to use Raphale JS graphics library. I would like to use the attribute gradient which should accept an object. Documentation says to refer to SVG specs. I found the gradient object in SVG, for instance <linearGradient id="myFillGrad" x1="0%" y1="100%" x2="100%" y2="0%"> <stop offset="5%" stop-color="red" /> <stop offset...

How do you get the "object reference" of an object in java when toString() and hashCode() have been overridden?

I would like to print the "object reference" of an object in Java for debugging purposes. I.e. to make sure that the object is the same (or different) depending on the situation. The problem is that the class in question inherits from another class, which has overriden both toString() and hashCode() which would usually give me the id. ...

Can I use blocks to manage scope of variables in C++?

Hi, I'm trying to gain some memory saving in a C++ program and I want to know if I can use blocks as a scope for variables (as in Perl). Let's say I have a huge object that performs some computations and gives a result, does it makes sense to do: InputType input; ResultType result; { // Block of code MyHugeObject mho; resu...

Ajax call back function scope & chaining Ajax request with callback.

Ok. here's the scenario: function DataFeed(){ function PopulateData() { $('div#example').load('http://www.example.com', fxnCallBack); }; function fxnCallBack() { PopulateData(); } this.activator = function() { PopulateData(); } }; var example_obj = new DataFeed; example_obj.activator(); In the above co...

What is the best way to convert an Address object to a String?

I have an Address object that has properties AddressLine1, AddressLine2, Suburb, State, ZipCode. (there are more but this is enough for the example). Also, each of these properties are strings. And I'm using C# 3.0. I'm wanting to represent it as a string but as I'm doing that I'm finding that I'm creating a method with a high cyclomati...

PHP object keeping

Let's say that in my app I have an object instance created on page 1. The user then goes to some other part of app and I want the instance to remain. How can I 'save' the instance? Sessions? ...

WPF ListBox ListCollectionView anonymous type navigation problem

Example of problem: Framework: WPF Visual control: DataGrid from CodePlex public Window() { InitializeComponent(); var listView = new ListCollectionView( new[] { new { Bool = false, Str = "Value1" }, new { Bool = false, Str = "Value1" }...