object

JavaScript new keyword and objects scopes

Later today, I was scrolling through ejhon.com slides and I found out the following: Give this code function katana () { this.myvar = true; } katana (); console.info (myvar); Past the moment I compiled the code, I thought that myvar is attached to the katana function. Actually, it gets attached to the window objects, which pollutes t...

PHP: get a single key from object

I have an object with a single key and its value. But I don't know the key to access it. What is the most efficient way to get the key without enumerating the object? ...

sharing a string between two objects

I want two objects to share a single string object. How do I pass the string object from the first to the second such that any changes applied by one will be visible to the other? I am guessing that I would have to wrap the string in a sort of buffer object and do all sorts of complexity to get it to work. However, I have a tendency...

C++ - Sort multidimensional vector by its contained object property

Hi guys, I've got a bidimensional array of objects (a 2D vector containing GridCell instances) as in here: typedef vector<GridCell> CellArray; typedef vector<CellArray> TwoDCellArray; TwoDCellArray CellArr2D; I am currently drawing all the cells like this: for (int i = 0; i < rows; i++){ for (int j = 0; j < cols; j++){ C...

XML to Java Object

Possible Duplicate: Java converting XML to Java objects Hi, Can someone please suggest the best and different ways of converting a XML file to an Java object? Thanks & Regards, Ravi. ...

can we assign an Exception Class object to the reference of Object class object

why this is will not work, can any one give the exact answer for this one.... public class Manager { public static void main(String args[]) { try{ Object obj=new A(); //it will generate ClassNotFoundException object System.out.println("currently the reference obj is pointer to the ...

Problem with objects in php

Hi. I am trying to get used to writing object oriented, but often I get a little stuck. I have this queries that I want to use to create arrays. $user1 = mysql_fetch_object(mysql_query("SELECT * FROM tbl WHERE username='$oc->user1'")); $user2 = mysql_fetch_object(mysql_query("SELECT * FROM tbl WHERE username='$oc->user2'"...

Junit test of the same object

Hi i want to make a unit test suite on same object with same variable but different values But if the object get the same name (created by this.setName("testlaunch"); (who must have the name of a function launch by junit), it makes only one test. if i don't write this.setName("testlaunch"); he shout on me an [code]junit.framework.Assert...

In Java what happens when an object fails to be instantiated?

I come from a c++ background and I find myself constantly doing this in java: SomeClass sc=new SomeClass(); if(null!=sc) { sc.doSomething(); } What I want to know is what will be in the variable sc if the constructor fails for some reason (like maybe not enough memory). I can' t find a straight answer, and I am worried that I am...

C++ - How to call creator class/object

Hi guys, I need to call properties and functions of an object from a different class. The idea is passing 'this' as a parameter to the other class constructor. E.g.: instance = ClassName(this); And then do: ParentClass parentInstance; ClassName::ClassName(MainApp _instance){ parentInstance = _instance; } However, my compiler ...

What is the base of all interfaces in .net, just like the base for all classes is the object

I would like to pass an interface to a method signature which takes Object as its parameter, so I wonder about this question public Stream GetViewStream(string viewName, object model, ControllerContext context) instead of object I shall like to pass an interface Imodel, without modifying the signature. Is there a base class for inter...

deleting an object in C++

Here is a sample code that I have: void test() { Object1 *obj = new Object1(); . . . delete obj; } I run it in Visual Studio, and it crashes at the line with 'delete obj;'. Isn't this the normal way to free the memory associated with an object? I realized that it automatically invokes the destructor... is this normal? ...

Is everything an object in ruby?

Is everything in ruby an object? Does this include Fixnums? ...

a compiler generated default constructor in c++

Hi, declaring a struct Table: struct Tables { int i; int vi[10]; Table t1; Table vt[10]; }; Tables tt; assuming that a user-deault contructor is defined for Table. here tt.t1 will be initialized using the default contructor for Table, as well as each element in tt.vt. On the other hand tt.i and tt.vi are...

JQuery Draggable and an <object> with an SVG?

I have an SVG file within an object tag displaying in a table cell,and I want to make the SVG draggable within the table cell using JQuery's Draggable. The code--minus the confusing bits in the tag, looks like this: <div id="container"> <div id="box"> <table align="center" border="1"> <tr> <td valign="middle">button</...

Visual Basic: dynamically create objects using a string as the name

Is there a way to dynamically create an object using a string as the class name? I've been off VB for several years now, but to solve a problem in another language, I'm forced to develop a wrapper in this one. I have a factory method to dynamically create and return an object of a type based on input from elsewhere. The provided input...

Saving data to plist per object or person

hi guys, i am trying to save data to the plist in my app per person, but it save it to everyone, so for example if i have a field for eye color and i enter brown in the textfield for john doe, it save brown for everyone else as well, is there a way to save this info per person in the app instead using plist, i have had no luck trying th...

How to make a visual reuasable class in C#?(Visual Studio 2010)

i have this class for example: class labeledtext { private TextBox tb; private Label l; public labeledtext(Form frm) { tb = new TextBox(); l = new Label(); frm.Controls.Add(tb); frm.Controls.Add(l); } public void SetCaption(string cpt) { l.Text = cpt; } public s...

How should I store an object in an asp.net web service so that business objects can reference the object?

I am building an ASP.NET web service that will be used internally in my company. Exception and trace/audit logging will be performed by the web service class as well as the business objects that the web service will call. The logging is handled by an instance of an internally developed log helper class. The log helper must be an insta...

Prototype: Array is an Object and not array?

I've been coding javascript like this: var Foo = { something: function() { }, someValue: 0, someArray: [], someObject: {}, anotherFunction: function (id) { this.someArray.push(id); // works - adds value to array someArray }, removeSomething: function(id) { this.someArray.without(id); //...