0

I'm trying to pass "this" as an argument of a constructor.

Is there any way can determine what the type of Object "this" is?

Thanks....

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by bruceaj
0

There is no reason you'd ever pass "this" as an argument. "this" just refers to the Object of the classtype that you are currently in. So if your class name is Car, and you say "this." anywhere within a method (other than main) in the Car class, then "this." refers to the instance i.e. the Car Object. So passing "this" to a constructor makes no sense, unless you are in a situation where composition/aggregation is involved. (And even then you'd typically not need to use the "this" keyword).

0

Okay.. I'll have to rethink what I'm doing. I thought it was "fishy" when I trying to do. Thanks for the explaination....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.