Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 26th, 2005, 06:25 AM
meendar
Guest
 
Posts: n/a
Default 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?

  #2  
Old December 26th, 2005, 12:45 PM
Bob Hairgrove
Guest
 
Posts: n/a
Default 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
  #3  
Old December 26th, 2005, 04:55 PM
Mateusz Łoskot
Guest
 
Posts: n/a
Default 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
  #4  
Old December 26th, 2005, 07:55 PM
Bob Hairgrove
Guest
 
Posts: n/a
Default 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
  #5  
Old December 26th, 2005, 08:05 PM
Mateusz Łoskot
Guest
 
Posts: n/a
Default 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
  #6  
Old December 27th, 2005, 01:15 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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.


  #7  
Old December 27th, 2005, 01:45 AM
Mateusz oskot
Guest
 
Posts: n/a
Default 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
  #8  
Old December 27th, 2005, 02:15 AM
Jonathan Mcdougall
Guest
 
Posts: n/a
Default 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

  #9  
Old December 27th, 2005, 11:35 AM
Mateusz Łoskot
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles