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

Constructor and destructor

P: 1
Dear Sir,
I want to know :

Why hould constructor be public member of class.

How are constructor and destructors called explictly. What is the difference between calling method for constructor and destructor. Is it possible for a constructor and destructor to call each other?

Thanks & Regards

Abhi
Mar 14 '07 #1
Share this Question
Share on Google+
1 Reply


DeMan
100+
P: 1,806
Constructor needs to be public so that people who want to construct an instance of a class can see it....

As for calling method v constructor/destructor it depends what you mean. A method does something and retunrs a result, a Constructor creates an instance of a class (and returns itself) (and I'm not real familiar with destructors, but I would imagine that they do all the necessary clean up to get rid of an instance of a class).

I would imagine it is possible for a Constructor and Destructor to call each other, but I can't really imagine why you might want to do that.
Mar 14 '07 #2

Post your reply

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