473,406 Members | 2,217 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,406 software developers and data experts.

baffled

M
I have a class with a constructor:

public nerd(int userId, int locNo, int divNo)
{

location = 1010;

}

If I call a method/func that uses the above, like so:

public nerd myMethod(1,1111, 0)

the return object shows a location value of 1010, not 1111!

Why is this?

Thank you !

Nov 15 '05 #1
7 1100
Because you are setting location to 1010? I see no indication that it
should ever be anything else.

Maybe the real story is more complicated?

"M" <mi******@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have a class with a constructor:

public nerd(int userId, int locNo, int divNo)
{

location = 1010;

}

If I call a method/func that uses the above, like so:

public nerd myMethod(1,1111, 0)

the return object shows a location value of 1010, not 1111!

Why is this?

Thank you !

Nov 15 '05 #2
Maybe I am missing something but you are explicitly saying "location =
1010". The value "1111" never gets used.

"M" <mi******@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I have a class with a constructor:

public nerd(int userId, int locNo, int divNo)
{

location = 1010;

}

If I call a method/func that uses the above, like so:

public nerd myMethod(1,1111, 0)

the return object shows a location value of 1010, not 1111!

Why is this?

Thank you !

Nov 15 '05 #3
M

oops.

I should have said
public nerd(int userId, int locNo, int divNo)
{

location = locNo;

}

I'm still working on this, help is very much appreciated!
Sorry for the confusion.
M wrote:
I have a class with a constructor:

public nerd(int userId, int locNo, int divNo)
{

location = 1010;

}

If I call a method/func that uses the above, like so:

public nerd myMethod(1,1111, 0)

the return object shows a location value of 1010, not 1111!

Why is this?

Thank you !


Nov 15 '05 #4
M

Um, I still didn't write this out correctly.

My code only calls the "new" nerd to instantiate a nerd object within
the myMethod function. When I return the nerd from MyMethod, upon
examination, no values have been changed. This function works fine,
EXCEPT now that I have a constructor in the nerd class, MyMethod no
longer writes values the way I think it should.

A little more code to show what I am talking about:

public nerd MyMethod(int userId, int locNo, int divNo)
{
nerd myNerd = new nerd(userId, 1010, divNo) //this should call the
constructor which sets the location property to 1010.

nerd.location = 1111;
return nerd;

}

BUT...when I examine the nerd object, nerd.location = 1010!

M wrote:

oops.

I should have said
public nerd(int userId, int locNo, int divNo)
{

location = locNo;

}

I'm still working on this, help is very much appreciated!
Sorry for the confusion.
M wrote:
I have a class with a constructor:

public nerd(int userId, int locNo, int divNo)
{
location = 1010;
}

If I call a method/func that uses the above, like so:

public nerd myMethod(1,1111, 0)

the return object shows a location value of 1010, not 1111!

Why is this?

Thank you !


Nov 15 '05 #5
M
I figured it out.

Nov 15 '05 #6
On Thu, 16 Oct 2003 20:02:15 -0500, M <mi******@hotmail.com> wrote:
public nerd MyMethod(int userId, int locNo, int divNo)
{
nerd myNerd = new nerd(userId, 1010, divNo) //this should call the
constructor which sets the location property to 1010.

nerd.location = 1111;
return nerd;

}


Does that even compile?
How about trying :
myNerd.location=1111;
return myNerd;

bullshark
Nov 15 '05 #7

"M" <mi******@hotmail.com> wrote in message
news:vo************@corp.supernews.com...
I figured it out.


What was the *real* problem and what was the solution?
Nov 15 '05 #8

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

Similar topics

2
by: Lazareth S. Link | last post by:
Hiya to whoever might stumble across this. I've recently taken up learning how to script/program in python. I've made my first program, a simple fahrenheit-celsius converter, both ways. For...
4
by: Mark Thomas | last post by:
Hi I do not understand why the following does not compile under Visual C++ 7.1. It is just a simple "Hello, World" program. // Hello World Application. Why does this fail? #include <iostream>...
6
by: Doug Baroter | last post by:
Hi, Don't worry about the vars, they are defined, the following line give me an err of "Incorrect syntax near '.'." Goal: to rename nonstardard column name. EXEC sp_rename...
4
by: Steve K | last post by:
While I'm no css guru by any stretch, I thought I knew more than this, guess not. I'm trying to come up with a style for a few lines of text that are secondary to the text above them, so I want...
13
by: s_m_b | last post by:
I'm building a suite of online forms for insurance. These have been stripped down from messy MS Word templates, and two of the six, substantially identical, are misbehaving with the .js page that...
4
by: Tim Robinson | last post by:
Hi, I generally consider myself competent with the complexities of quoting but I can't figure out postgres at all. I've read the manual and it looks very straightforward but that doesn't accord...
17
by: sheldonlg | last post by:
I need to do some modifications on some code I just inherited and that code has me baffled. On one page, caller.php, with method get there is an anchor with href="foo.php?bar=123". On foo.php,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.