Connecting Tech Pros Worldwide Help | Site Map

Default call of an Empty class object

meendar
Guest
 
Posts: n/a
#1: Dec 26 '05
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?

Bob Hairgrove
Guest
 
Posts: n/a
#2: Dec 26 '05

re: Default call of an Empty class object


On 25 Dec 2005 22:15:51 -0800, "meendar"
<askjavaprogrammers@gmail.com> wrote:
[color=blue]
>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?[/color]

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
NoSpamPlease@Home.com
Mateusz Łoskot
Guest
 
Posts: n/a
#3: Dec 26 '05

re: Default call of an Empty class object


Bob Hairgrove wrote:[color=blue]
> On 25 Dec 2005 22:15:51 -0800, "meendar"
> <askjavaprogrammers@gmail.com> wrote:
>
>[color=green]
>> 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?[/color]
>
>
> C++ has no "methods", only functions and member functions.[/color]

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
Bob Hairgrove
Guest
 
Posts: n/a
#4: Dec 26 '05

re: Default call of an Empty class object


On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot
<see.my@signature.net> wrote:
[color=blue]
>Bob Hairgrove wrote:[color=green]
>> C++ has no "methods", only functions and member functions.[/color]
>
>Isn't it a naming convention?[/color]

No.
[color=blue]
>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[/color]

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

--
Bob Hairgrove
NoSpamPlease@Home.com
Mateusz Łoskot
Guest
 
Posts: n/a
#5: Dec 26 '05

re: Default call of an Empty class object


Bob Hairgrove wrote:[color=blue]
> On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot[color=green]
>>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)"[/color]
>
> I have the original ... it says "Member functions".
>[/color]

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
Victor Bazarov
Guest
 
Posts: n/a
#6: Dec 27 '05

re: Default call of an Empty class object


Mateusz Loskot wrote:[color=blue]
> Bob Hairgrove wrote:[color=green]
>> On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot[color=darkred]
>>> 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)"[/color]
>>
>> I have the original ... it says "Member functions".
>>[/color]
>
> Hm, in my copy (translation of 3rd edition) I have explicitly
>
> "member function (method)"
>
> I have word "method" in parenthesis.[/color]

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


Mateusz oskot
Guest
 
Posts: n/a
#7: Dec 27 '05

re: Default call of an Empty class object


Victor Bazarov wrote:[color=blue]
>[color=green]
>> Hm, in my copy (translation of 3rd edition) I have explicitly
>>
>> "member function (method)"
>>
>> I have word "method" in parenthesis.[/color]
>
> How can a Polish translation have English words in it? And don't
> mean the source code.
>[/color]

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
Jonathan Mcdougall
Guest
 
Posts: n/a
#8: Dec 27 '05

re: Default call of an Empty class object


Mateusz Loskot wrote:[color=blue]
> Victor Bazarov wrote:[color=green]
> >[color=darkred]
> >> Hm, in my copy (translation of 3rd edition) I have explicitly
> >>
> >> "member function (method)"
> >>
> >> I have word "method" in parenthesis.[/color]
> >
> > How can a Polish translation have English words in it? And don't
> > mean the source code.
> >[/color]
>
> 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)..."[/color]

This was added in the translation. The original reads

"Functions declared within a class definition [..] are called member
functions and can be invoked [...]"
[color=blue]
> Another chapter title:
>
> 10.2.6 Metody stale
>
> what means: "Const methods"[/color]

The original reads "Constant Member Functions".
[color=blue]
> As I said, may be this translation is not accurate.
> And - what I understand from Bob's posts - this translation
> may be even incorrect.[/color]

It is.


Jonathan

Mateusz Łoskot
Guest
 
Posts: n/a
#9: Dec 27 '05

re: Default call of an Empty class object


Jonathan Mcdougall wrote:[color=blue]
> Mateusz Loskot wrote:
>[color=green]
>>As I said, may be this translation is not accurate.
>>And - what I understand from Bob's posts - this translation
>>may be even incorrect.[/color]
>
>
> It is.
>[/color]

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