By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,857 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

A question about pointers

P: n/a
Hello Experts!

I have this statement
Student* john = michael;
where the pointer john is pointing to the same class object that michael is
pointing at.
But now to my question.will the copy constructor for the Student class be
called or any other constructor.

Many thanks.
//Tony
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Tony Johansson wrote:
Hello Experts!

I have this statement
Student* john = michael;
where the pointer john is pointing to the same class object that michael
is pointing at.
But now to my question.will the copy constructor for the Student class be
called or any other constructor.


No.

Jul 23 '05 #2

P: n/a
Hello Tony:
The john's type is pointer(not Student) and points to a Student object.
It is nearly the same as int. Its value is an address. Therefore, the
Student's copy constructor will not called. If the code is as the
follow:
Student john = michael;//michael is a Student object. john's type is
Student,not pointer
the Student's copy constructor will be called.

Jeremiah L.Jiang

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.