C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Default Member Functions

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Morris
Guest





PostPosted: Thu Jun 24, 2004 6:31 am    Post subject: Default Member Functions Reply with quote



I have a question.

How many functions are defined by default when you define a class.

I was aware of four functions:
Constructor
Destructor
Assignment Operator
Copy Contructor

I over heard somewhere that there are six functions by default in a class.

Can anyone please tell me what are the other two default functions in a class.

Regards,
morris
Back to top
cyper
Guest





PostPosted: Thu Jun 24, 2004 7:17 am    Post subject: Re: Default Member Functions Reply with quote




"Morris" <lattice (AT) flashmail (DOT) com> ????
news:3e2b79b0.0406232231.6f8169ab (AT) posting (DOT) google.com...
Quote:
I have a question.

How many functions are defined by default when you define a class.

I was aware of four functions:
Constructor
Destructor
Assignment Operator
this one isn't always needed.

when it isn't exist.they would auto call copy construtor

Quote:
Copy Contructor

I over heard somewhere that there are six functions by default in a class.

Can anyone please tell me what are the other two default functions in a
class.

Regards,
morris



Back to top
Karl Heinz Buchegger
Guest





PostPosted: Thu Jun 24, 2004 8:18 am    Post subject: Re: Default Member Functions Reply with quote



cyper wrote:
Quote:

"Morris" <lattice (AT) flashmail (DOT) com> ????
news:3e2b79b0.0406232231.6f8169ab (AT) posting (DOT) google.com...
I have a question.

How many functions are defined by default when you define a class.

I was aware of four functions:
Constructor
Destructor
Assignment Operator
this one isn't always needed.
when it isn't exist.they would auto call copy construtor

Not sure what you mean with that, your english is very hard to understand.
But in any case it sounds wrong.

operator= and copy constructor do different things. The compiler
will never (and can't do it) substitute operator= with a call to
the copy constructor or vice versa. If it needs an operator= there
has to be one, or the compiler emits an error.

--
Karl Heinz Buchegger
[email]kbuchegg (AT) gascad (DOT) at[/email]

Back to top
Sree
Guest





PostPosted: Thu Jun 24, 2004 11:15 am    Post subject: Re: Default Member Functions Reply with quote


Also, it is doubtfull, that the compiler offers you a default constructor and
destructor, you need to explicitly put that in your code. There are wizards in
IDEs which will help you in this, but that is offtopic here.

--
Use our news server 'news.foorum.com' from anywhere.
More details at: http://nnrpinfo.go.foorum.com/
Back to top
Howard
Guest





PostPosted: Thu Jun 24, 2004 6:55 pm    Post subject: Re: Default Member Functions Reply with quote


"Sree" <no_spam_please (AT) f-m (DOT) fm> wrote

Quote:

Also, it is doubtfull, that the compiler offers you a default constructor
and
destructor, you need to explicitly put that in your code. There are
wizards in
IDEs which will help you in this, but that is offtopic here.

--

I think you're misunderstanding. The "default" constructor and/or
destructor are created if needed, but they are not created as source code
that gets inserted in your .cpp file. They are created in the resulting
object code, however. Suppose, for example, that your class contained and
instance of another class. The constructor for that contained class has to
be called, and that's done via the default constructor that's created for
your class (assuming you haven't provided one).

-Howard




Back to top
Prateek R Karandikar
Guest





PostPosted: Thu Jun 24, 2004 11:38 pm    Post subject: Re: Default Member Functions Reply with quote

[email]lattice (AT) flashmail (DOT) com[/email] (Morris) wrote in message news:<3e2b79b0.0406232231.6f8169ab (AT) posting (DOT) google.com>...
Quote:
I have a question.

How many functions are defined by default when you define a class.

I was aware of four functions:
Constructor
Destructor
Assignment Operator
Copy Contructor

I over heard somewhere that there are six functions by default in a class.

Can anyone please tell me what are the other two default functions in a class.

Regards,
morris

The other 2 are the unary & and the comma operator. Note that only the
in-built or compiler-generated comma has the sequence point, not any
user-defined ones.

-- --
Abstraction is selective ignorance.
-Andrew Koenig
-- --

Back to top
Morris
Guest





PostPosted: Sun Jun 27, 2004 1:44 pm    Post subject: Re: Default Member Functions Reply with quote

[email]kprateek88 (AT) yahoo (DOT) com[/email] (Prateek R Karandikar) wrote in message
Quote:
Can anyone please tell me what are the other two default functions in a class.

Regards,
morris

The other 2 are the unary & and the comma operator. Note that only the
in-built or compiler-generated comma has the sequence point, not any
user-defined ones.

Thanx for the answer. Can someone please provide me pointer to some
text(preferably electronic) where I can get more info on the same.

Or some section of Stroustrup's book which gives info regarding the
same.

Regards,
morris

Quote:

-- --
Abstraction is selective ignorance.
-Andrew Koenig
-- --

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.