473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Default call of an Empty class object

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?

Dec 26 '05 #1
8 5705
On 25 Dec 2005 22:15:51 -0800, "meendar"
<as****************@gmail.com> wrote:
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?


C++ has no "methods", only functions and member functions.

What do you mean by empty? No data members? No member functions?

An object by itself does not call any functions. Your program calls
the functions. The constructor (or one constructor out of several if
there are more than one) is called when the object is created, and the
destructor is called when it is destroyed. But your program is
responsible for creation and deletion, so here it is also your program
that calls these, at least indirectly.

Consider the following:

struct Empty {};

I suppose that is as close as one can come to an empty class. However,
the C++ standard requires stand-alone objects of such empty classes to
have non-zero size (see section 9.2). If Empty is used as a base
class, the compiler is allowed to optimize its size away to zero bytes
within the derived class. Since we declared no default constructor,
destructor or assignment operator, the compiler generates these for
us. You can create objects of this class. Such empty classes are often
used in exception handling where the type is the only thing of
interest.

--
Bob Hairgrove
No**********@Home.com
Dec 26 '05 #2
Bob Hairgrove wrote:
On 25 Dec 2005 22:15:51 -0800, "meendar"
<as****************@gmail.com> wrote:

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?

C++ has no "methods", only functions and member functions.


Isn't it a naming convention?
Word "method" is used also in the "The C++ Programming Language", 3rd
Ed. by Bjarne Stroustrup, chapter 10.2.1 (I have only polish
translation, so I'm not able to quote the original):

"member function (method)"

Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 26 '05 #3
On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot
<se****@signature.net> wrote:
Bob Hairgrove wrote:
C++ has no "methods", only functions and member functions.
Isn't it a naming convention?


No.
Word "method" is used also in the "The C++ Programming Language", 3rd
Ed. by Bjarne Stroustrup, chapter 10.2.1 (I have only polish
translation, so I'm not able to quote the original):

"member function (method)"

Cheers


I have the original ... it says "Member functions".

--
Bob Hairgrove
No**********@Home.com
Dec 26 '05 #4
Bob Hairgrove wrote:
On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot
Word "method" is used also in the "The C++ Programming Language", 3rd
Ed. by Bjarne Stroustrup, chapter 10.2.1 (I have only polish
translation, so I'm not able to quote the original):

"member function (method)"


I have the original ... it says "Member functions".


Hm, in my copy (translation of 3rd edition) I have explicitly

"member function (method)"

I have word "method" in parenthesis.
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 26 '05 #5
Mateusz Loskot wrote:
Bob Hairgrove wrote:
On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot
Word "method" is used also in the "The C++ Programming Language",
3rd Ed. by Bjarne Stroustrup, chapter 10.2.1 (I have only polish
translation, so I'm not able to quote the original):

"member function (method)"


I have the original ... it says "Member functions".


Hm, in my copy (translation of 3rd edition) I have explicitly

"member function (method)"

I have word "method" in parenthesis.


How can a Polish translation have English words in it? And don't
mean the source code.
Dec 27 '05 #6
Victor Bazarov wrote:
Hm, in my copy (translation of 3rd edition) I have explicitly

"member function (method)"

I have word "method" in parenthesis.


How can a Polish translation have English words in it? And don't
mean the source code.


I said I'm not quoting, I'm translating back to english.
There is possibility that polish translator has changed the meaning of
those statements, so my re-translation is not accurate.

Victor, do you know polish?

Here are a few examples from Bjarne's book:
(without polish accents)

Title of the chapter:

10.2.1 Funkcje skladowe

It does mean "Member functions"

and inside the chapter is:

"Funkcje zadeklarowane wewnatrz definicji klasy nazywane funkcjami
skladowymi (metodami)..."

what does mean:

"Functions declared inside class definition are called member functions
(methods)..."

Another chapter title:

10.2.6 Metody stale

what means: "Const methods"

As I said, may be this translation is not accurate.
And - what I understand from Bob's posts - this translation
may be even incorrect.

Cheers
--
Mateusz oskot
http://mateusz.loskot.net
Dec 27 '05 #7
Mateusz Loskot wrote:
Victor Bazarov wrote:
Hm, in my copy (translation of 3rd edition) I have explicitly

"member function (method)"

I have word "method" in parenthesis.
How can a Polish translation have English words in it? And don't
mean the source code.


I said I'm not quoting, I'm translating back to english.
There is possibility that polish translator has changed the meaning of
those statements, so my re-translation is not accurate.

Here are a few examples from Bjarne's book:
(without polish accents)

Title of the chapter:

10.2.1 Funkcje skladowe

It does mean "Member functions"

and inside the chapter is:

"Funkcje zadeklarowane wewnatrz definicji klasy nazywane funkcjami
skladowymi (metodami)..."

what does mean:

"Functions declared inside class definition are called member functions
(methods)..."


This was added in the translation. The original reads

"Functions declared within a class definition [..] are called member
functions and can be invoked [...]"
Another chapter title:

10.2.6 Metody stale

what means: "Const methods"
The original reads "Constant Member Functions".
As I said, may be this translation is not accurate.
And - what I understand from Bob's posts - this translation
may be even incorrect.


It is.
Jonathan

Dec 27 '05 #8
Jonathan Mcdougall wrote:
Mateusz Loskot wrote:
As I said, may be this translation is not accurate.
And - what I understand from Bob's posts - this translation
may be even incorrect.

It is.


Thanks, now it's clear.
It's also a good argument for buying original books not translations.
Cheers
--
Mateusz Łoskot
http://mateusz.loskot.net
Dec 27 '05 #9

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

Similar topics

3
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to...
44
by: gregory.petrosyan | last post by:
Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ????) print x All I want is to make self.data the default argument for self.f(). (I
3
by: swengtoo | last post by:
In his book "More Effective C++", Scott Meyer suggests in "Item 4" to "Avoid gratuitous default constructors". To summarize his claims against default constructors for "the right classes" he...
10
by: Joel | last post by:
Is it true that if we don't specify a default constructor for our class, then the C# compiler provides us with its own that zeroes (or assigns default values) to the data members? I wrote a...
4
by: Jess | last post by:
Hello, I tried several books to find out the details of object initialization. Unfortunately, I'm still confused by two specific concepts, namely default-initialization and...
10
by: Brad Baker | last post by:
I have an asp.net/csharp application that requires a particular variable to work properly. This variable is usually passed via a query string in the URL when the application is first run but under...
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...
2
by: Jeff | last post by:
Hi I'm trying to achieve a scenario where I have c# files that are compiled dynamically, the assemblies are then loaded in a different AppDomain, I call a simple method from the object, and then...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.