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....

Recommended Answers

All 2 Replies

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).

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.