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

object declarations

bucketbot
just a quick questions that has been bugging me for a few days:

lets say i have some classes X and Y, and in some other part of the program, I make this declaration:

X xObject = new yObject();

What does that do?

thanks
Jun 5 '07 #1
5 1069
just a quick questions that has been bugging me for a few days:

lets say i have some classes X and Y, and in some other part of the program, I make this declaration:

X xObject = new yObject();

What does that do?

thanks
that does not work
but you can cast to do that
ex: X xObject =(X)( new yObject());
Jun 5 '07 #2
that does not work
but you can cast to do that
ex: X xObject =(X)( new yObject());
of course if casting is allowed which will depend on the types of x and y
Jun 5 '07 #3
r035198x
13,262 8TB
just a quick questions that has been bugging me for a few days:

lets say i have some classes X and Y, and in some other part of the program, I make this declaration:

X xObject = new yObject();

What does that do?

thanks

You can do
Expand|Select|Wrap|Line Numbers
  1.  List c = new ArrayList();
.

Think about it and come up with the instances where it is allowed to do so. Don't forget to test for interfaces as well ...
Jun 6 '07 #4
ok, lets say its type casted. i dont understand what the xObject becomes if the yObject is stored into it.

thanks
Jun 6 '07 #5
r035198x
13,262 8TB
ok, lets say its type casted. i dont understand what the xObject becomes if the yObject is stored into it.

thanks
How about you think about this in terms reference types and what they are pointing to?


e.g
Expand|Select|Wrap|Line Numbers
  1.  X x = new Y();
The reference x of type X is pointing to an object of type Y.
Jun 6 '07 #6

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

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
73
by: Water Cooler v2 | last post by:
I am new to PHP, just one day new. But I am otherwise a seasoned programmer on many other languages like C, VB 6, C#, VB.NET, Win32 platform and have some tiny bit experience in MFC, C++, Python. ...
36
by: zouyongbin | last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this should not appear in a header file: int ix; The inclusion of any of these definitions in two or more files of the same...
4
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.