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? 8 5743
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**********@Ho me.com
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
On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskot
<se****@signatu re.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**********@Ho me.com
Bob Hairgrove wrote: On Mon, 26 Dec 2005 17:44:46 +0100, Mateusz ?oskotWord "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
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.
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 set default values for most
properties so the control will work as-is without requiring the developer to
set them.
I notice in the compment initialization code create when I drop the control
on a form that all the properties are set to null or...
|
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
|
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 states that:
================== START QUOTE =============
"A default constructor is the C++ way of saying you can get something
for nothing. Constructors initialize objects, so default constructors
initialize objects without any information from...
|
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 no-parameter constructor for my class with an
empty function body. I then instantiated an object and tried
printing its values, amazingly the members were already initialized.
But how is this possible if I have not included any code for doing
so. The...
|
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 value-initialization. I
think default-init calls default constructor for class objects and
sets garbage values to PODs. Value-init also calls default
constructor for class objects and sets 0s to POD types. This is what
I've learned from the books (especially...
| |
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 certain circumstances the query
string may not contain the variable. So I need some way of establishing a
default value if one isn't set.
Is there some way I can set a query string on page_load OR is there some way
I can use a global variable...
|
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 "there is no difference between a struct
and a class except the public/private access specification" (and a few minor
other things). When I create a class, I always start by declaring the
default constructor, copy constructor and assignment operator...
|
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 virtual function;
2. virtual inheritance;
3.base class with explicit default constructor;
|
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 unload the AppDomain to release
the lock on the assemly files (so to I can compile the code again if it has
been modified). However, I've encountered a problem, whereby the assembly is
also loaded in the default AppDomain!
I have a few classes...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |