473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Default Member Functions

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
Jul 22 '05 #1
6 2831

"Morris" <la*****@flashmail.com> ????
news:3e**************************@posting.google.c om...
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
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

Jul 22 '05 #2
cyper wrote:

"Morris" <la*****@flashmail.com> ????
news:3e**************************@posting.google.c om...
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
kb******@gascad.at
Jul 22 '05 #3

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/
Jul 22 '05 #4

"Sree" <no************@f-m.fm> wrote in message
news:20******************@foorum.com...

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

Jul 22 '05 #5
la*****@flashmail.com (Morris) wrote in message news:<3e**************************@posting.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
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
-- --
Jul 22 '05 #6
kp********@yahoo.com (Prateek R Karandikar) wrote in message
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

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

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: earl | last post by:
class temp { public: temp(); foo(char, char, char*); private: char matrix; }; temp::foo(char p, char o, char m = matrix )
16
by: jonathan cano | last post by:
QUESTION: In practice, lines 36 and 37 below are usually equivalent to the default copy constructor (.e.g line 33). My questions are: (a) Does ISO 14882 guarantee that lines 36 and 37 are...
8
by: meendar | last post by:
what will a object of an Empty class( contain nothing), do on default.What are all the default methods it calls. what is the use of creating the object for an empty class?
15
by: Youssef Mesri | last post by:
What is the difference between these two situations: 1- hold a namespace which contains justs some functions: namespace MyNamespace { void foo1(); void foo2(); void foo3(); void foo4();
9
by: Peter Oliphant | last post by:
I've been told that value structs can have default constructors (I'm using VS C++.NET 2005 PRO using clr:/pure syntax). But the following code generates the following error: value struct...
22
by: sujilc | last post by:
This question seems to be silly. Can ony one figure out the default functions implemented by compiler when we decalre a class like class A { } According to me this declaration will define...
5
by: Martijn van Buul | last post by:
Hi. I'm having a peculiar problem at work. I've been googling for it, but haven't found an authorative answer. In a nutshell (Long story follows), what I'd like to know is: If I have a C++...
43
by: JohnQ | last post by:
Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because...
10
by: JosephLee | last post by:
In Inside C++ object Model, Lippman said there are four cases in which compile will sythesize a default constructor to initialize the member variables if the constructor is absent: 1. there is a...
0
by: Frank Bergemann | last post by:
Using gcc-4.3.0 it silenty(!) invokes the Test::operator=(Test const& t) for Test a; Test b = std::move(a); Test c = std::moved(T()); - if i disable the Test::operator=(Test&& t) in source...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.