objects

C++: What is the size of an object of an empty class?

I was wondering what could be the size of an object of an empty class. It surely could not be 0 bytes since it should be possible to reference and point to it like any other object. But, how big is such an object? I used this small program: #include <iostream> using namespace std; class Empty {}; int main() { Empty e; cerr <<...

Why can't I directly add attributes to any python object?

I have this code: >>> >>> class G: ... def __init__(self): ... self.x = 20 ... >>> gg = G() >>> gg.x 20 >>> gg.y = 2000 and this code : >>> from datetime import datetime >>> my_obj = datetime.now() >>> my_obj.interesting = 1 *** AttributeError: 'datetime.datetime' object has no attribute 'interesting' From my python knowled...

C# Scope of variables vs objects when parameterized into methods

I make extensive use of inheritance, polymorphisim, and encapsulation but i just realised that i didn't know the following behavior about scope of an object vs a variable. The difference is best shown with code: public class Obj { public string sss {get; set;} public Obj() { sss = "0"; } } public partial ...

How can I search for a value in an object?

I have a PHP script that goes through an XML file, but I want to be able to search the object for a value, just like I can search an array for a value. According to comments on PHP.net, array_search() supports objects as of PHP5, but I can't get it to work. The XML file is a list for bus stops, and I want to be able to search through t...

Object property "Previous Value" in Javascript

I'm just starting to get my mind around this whole Object Oriented thing, so bear with me. So, I saw an example of an object function (for Javascript) where you assign a new value and that value gets assigned as that property's actual value. Example: function Meat (name, color, price) { function newPrice (new_price) { this....

Declaring class objects in a header file

Greetings everyone. I seem to be snagging on a fundimental but I cant find the solution anywhere. Anywho, will go ahead and explain. I have a program consisting of three files; main.ccp, add.h, add.cpp. I declare the class 'SA' in add.h and have all my functions defined in add.cpp additional.h class SA { ... public int x; } ...

How to diff two versions of same object ?

I want to compare two objects of different versions and display their differences in UI. First I call a method to know if there is any difference between the two objects The method is: public bool AreEqual(object object1,object object2, Type comparisionType) If the above method returns true, I call the GetDifferences method to get t...

Object integrity and caching in a stateful client

I'm wondering what strategies exist to handle object integrity in a stateful client like a Flex or Silverlight app. What I mean is the following: consider an application where you have a Group and a Member entity. Groups contain multiple members and members can belong to multiple groups. A view lists the different groups, which are laz...

Method in Objective-C that points to an object

I have created a few sprites using a spriteclass and I have loaded them into an array. In my app, I loop over the array checking for particular conditions (position, etc.). I want to create an explosion method that I can pass one of these objects to and then using the pointer pull the position of the object on the screen and show an expl...

Should a list of objects be stored on the heap or stack?

I have an object(A) which has a list composed of objects (B). The objects in the list(B) are pointers, but should the list itself be a pointer? I'm migrating from Java to C++ and still haven't gotten fully accustomed to the stack/heap. The list will not be passed outside of class A, only the elements in the list. Is it good practice to a...

Duplicating arrays when equalizing Objects.

Greetings everyone. I'm in need of some experiance here as how to deal with dynamic arrays with Objects. I've a class 'SA', consisting of several objects 'Obj1', 'Obj2' etc... Within the class I have a dynamic array 'SA_Array' which I initialize in the following manner where size sets its length: double * SA_Array; SA_Array = new doub...

Accessing Microsoft Automation Objects from Python

I have a set of macros that I have turned into an add-in in excel. The macros allow me to interact with another program that has what are called Microsoft Automation Objects that provide some control over what the other program does. For example, I have a filter tool in the add-in that filters the list provided by the other program to ...

Populate array of objects from namevaluecollection in c#

I am new to C#. Here is a hard-coded thing I got working: InputProperty grantNumber = new InputProperty(); grantNumber.Name = "udf:Grant Number"; grantNumber.Val = "571-1238"; Update update = new Update(); update.Items = new InputProperty[] { grantNumber }; Now I want to generalize this to support an indefinite number of items in the...

Why doesn't this work? Calling functions belonging to objects in a loop.

In my code jsc.tools is an object containing objects. Each sub-object contains a init() and run() method. I have the following code running at startup: for(tool in jsc.tools) { tool.init(); } which gives me the error "tool.init is not a function". A sample of a tool's declaration is: jsc.tools.sometool = {}; jsc.tools.sometool.run...

Confused on C# Array of objects and implicit type conversion

I am trying to pass an array of a simple object to a web service and I'm really stuck on this error during compile of my web client project: Cannot implicitly convert type 'TRIMBrokerUtil.MetaData[]' to 'TRIMBrokerASMXProxy.ASMXProxy.MetaData[]' Here is my "utility" project compiled into TRIMBrokerUtil.dll: namespace TRIMBrokerUtil { ...

LINQ to Objects - Philosophy of use?

I am starting to explore LINQ to Objects but want to know how application design can best accommodate LINQ to Objects. As an example .... an application displays female employees only and the employee table in the database contains data for both male and female employees. By default, the application builds a SQL statement to retrieve ...

Different methods for instantiating an object in C++

What is the difference between this: Myclass *object = new Myclass(); and Myclass object = new Myclass(); I have seen that a lot of C++ libraries like wxWidgets, OGRE etc use the first method... Why? ...

Copy array of objects to array of different type

Previously, I ran into a problem trying to share a type definition between my ASMX webservice and my .aspx page (webclient) http://stackoverflow.com/questions/667619/confused-on-c-array-of-objects-and-implicit-type-conversion As I understand the advice, the "problem" this creates can be solved by copying the array of objects created in...

trying to store java objects in contiguous memory

Hi all, I am trying to implement a cache-like collection of objects. The purpose is to have fast access to these objects through locality in memory since I'll likely be reading multiple objects at a time. I currently just store objects in a java collections object like vector or deque. But I do not believe this makes use of contiguou...

How can I get rid of a persistent VBA Form Object that won't honor the form deletion?

I have an MS Access 2003 database that I'm using to develop a basic little inventory app. I have added some extraneous forms along the way and I wanted to get them out of the DB. I deleted most of them just fine but one of them appears to have left behind its VBA Object. All that's in the object is Option Compare Database. Now whenev...