473,466 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get name of the calling instance

110 New Member
Hey all ,

Is there a way to get the instance name at runtime? I had homework assignment to calculate great circle distance between two cities and a few conversions....Im done them all...except:

I instantiate two objects of the same type called A and B. Both A and B call method M.

I want to it so that if object A calls method M, M returns HEY, A. If object B calls method M, M returns HEY, B. I have my program working but I am convinced there has to be a better way to do this where the method M can tell which object is calling it and then decide what value to return....so is there a some built in member that can tell the name of the calling object?

I already googled but I am not even sure what to google for...
Oct 11 '07 #1
1 1989
Plater
7,872 Recognized Expert Expert
I am unaware of anything tha will do that explicitly.
If method M were a part of the class that A and B are, then it could look at internal members for the difference.
But without passing in a reference to the object in method M I'm not sure it can be done.

I think it's a little differently now but in the olden days:
int a=0;
int b=1;

"a" and "b" had no real meaning except the program, as when the program was compiled they were just symbols for memory addresses.
Oct 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
6
by: Raterus | last post by:
Hello, Does anyone have any ideas how I can accomplish this using properties. I'm trying to create a property, that acts like a structure. Basically I'm trying to create a property that I could...
14
by: Altman | last post by:
Ok I have a control that is inherited from another class. In the child I put msgbox(me.name) in the load event. What always pops up is the name of the parent class and not the name of the...
3
by: Rico | last post by:
Hello, I have a generic process that logs errors from different sources. When I call this code, I'd like to also submit the name of the function or sub that is raising the error without having...
6
by: =?Utf-8?B?SmFzb24gUmV5bm9sZHM=?= | last post by:
(using .net 2.0) Say you have a class structure like this: class Address .... end class class Person FirstName
1
daJunkCollector
by: daJunkCollector | last post by:
Is there a way that I can have the name of an instance's name appear in a dynamic textfield? I have a map with every county in the USA on it and I want the county's name to display on rollover. ...
8
by: Matthias Watermann | last post by:
Hi, I'm wondering if it's possible for an object to figure it's name. for example: function baseClass() { // setup properties of "baseClass" } baseClass.prototype = { aMethod: function() {
0
by: Maric Michaud | last post by:
Le Friday 05 September 2008 17:29:39 mercado mercado, vous avez écrit : Note that "self" for somemethod is just a local variable of the calling function. You cannot retrieve those local...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.