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...
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...
Is it like...
var obj = new Object();
obj.function1 = function(){
//code
}
or something like that?
...
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...
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?
...
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.
...
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?
...
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 ($...
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...
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...
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...
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...
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...
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...
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.
...
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...
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...
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...
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?
...
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"
}...