473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Weird object behaviour

Hi group,

I have an app where I use a class defined by myself. I've been using it
normally until a few days ago. Every time I run a simple assignment...

Dim LocalObjectOfMyClass as New MyClass
LocalObjectOfMyClass = GlobalObjectOfMyClass

....all of a sudden, I'm getting an strange behaviour where, after this
point, every change I make to any property or variable in the local
object occurs in the global object as well. They seem somehow linked.

So. Is there something I should inmediately check or do I go dive
deeply into my code? I mean... May this be happening for any obvious
reason I am missing? Or does it have to be something wrong in my code?

Thanks

Jul 21 '05 #1
3 1257
Looks expected to me.

You create a local object.
You then make this local object "point" to your global object.

Behind the scene objects are nothing else than pointers. When you assign an
object to another object you don't make a new "copy" the objet. You make
them point to the same location.

Patrice.

--

"Samuel Caparros" <mo****@ciudadparagon.com> a écrit dans le message de
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi group,

I have an app where I use a class defined by myself. I've been using it
normally until a few days ago. Every time I run a simple assignment...

Dim LocalObjectOfMyClass as New MyClass
LocalObjectOfMyClass = GlobalObjectOfMyClass

...all of a sudden, I'm getting an strange behaviour where, after this
point, every change I make to any property or variable in the local
object occurs in the global object as well. They seem somehow linked.

So. Is there something I should inmediately check or do I go dive
deeply into my code? I mean... May this be happening for any obvious
reason I am missing? Or does it have to be something wrong in my code?

Thanks

Jul 21 '05 #2
> Behind the scene objects are nothing else than pointers. When you
assign an
object to another object you don't make a new "copy" the objet. You make them point to the same location.


Whoa. Not such a strange behaviour then I guess. Ok, it's official now,
I'm a newbie.

Oh well, serious now. How do I make said "copy" of the object? I
mean...an exact duplicate I can later work "independently" with.

Thank you for answering, btw.

Jul 21 '05 #3
Try :
http://msdn.microsoft.com/library/de...clonetopic.asp

I f you have simple types it should be fairly simple (for a start you could
just copy properties ie Myobj.a=MyGernal.a:MyObj.b=MyGeneral.b etc...)
You may want to see :
http://msdn.microsoft.com/library/de...fVBSpec6_1.asp

The big picture may also help. Generally it's quite rare to need cloning
(here you could perhaps just have default values when the object is created,
from where are taken the properties of the global object ?)

Patrice
--

"Samuel Caparros" <mo****@ciudadparagon.com> a écrit dans le message de
news:11********************@f14g2000cwb.googlegrou ps.com...
Behind the scene objects are nothing else than pointers. When you

assign an
object to another object you don't make a new "copy" the objet. You

make
them point to the same location.


Whoa. Not such a strange behaviour then I guess. Ok, it's official now,
I'm a newbie.

Oh well, serious now. How do I make said "copy" of the object? I
mean...an exact duplicate I can later work "independently" with.

Thank you for answering, btw.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Philip Yale | last post by:
I'm very puzzled by the choice of NC index being made by the optimizer in this example. I don't actually think it should use an NC index at all. I have: Table: CustomerStatus_T Single data...
10
by: Chris Mantoulidis | last post by:
I see some really weird output from this program (compiled with GCC 3.3.2 under Linux). #include <iostream> using namespace std; int main() { char *s; s = "test1"; cout << "s = " << s << "...
0
by: pigwin32 | last post by:
I have an asp application that uses a javascript server side include to instantiate a component for generating our menu html. The component is pooled and worked perfectly on Windows 2000. On...
1
by: Pankaj | last post by:
Hi All, I use a Hashtable in my program to keep unique items...at one instance I need to repopulate this hashtable through a loop. when starting repopulation hashtable.count() returns ZERO...
8
by: Daniel Yelland | last post by:
Hi, I have developed a number of code libraries in Win32 DLLs and have written a number of test suite executables that implicitly link to these libraries in order to test them. In one of my test...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Samuel Caparros | last post by:
Hi group, I have an app where I use a class defined by myself. I've been using it normally until a few days ago. Every time I run a simple assignment... Dim LocalObjectOfMyClass as New MyClass...
41
by: Petr Jakes | last post by:
Hello, I am trying to study/understand OOP principles using Python. I have found following code http://tinyurl.com/a4zkn about FSM (finite state machine) on this list, which looks quite useful for...
2
by: ian | last post by:
Hi, I've got the weirdest garbage collection problem - I'd appreciate any advice you've got. 1. A class 'X' in a system I'm working on contains a reference to an XmlDocument, populated via...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.