Re: CreateInstance
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 6 Feb 2008 21:51:01 -0800
Thanks Alex,
The `sizeof' operator never yields 0, even for an empty class.
"sizeof Operator"
http://msdn2.microsoft.com/en-us/library/4s7x1k91.aspx
I have read the link and I found as you mentioned sizeof never results in 0
as result. How do you think for a class without data members, the result is
1?
(for the link you recommended, it does not cover the case why for a class
without data member, its size is 1).
regards,
George
"Alex Blekhman" wrote:
"George" wrote:.
Understand that. I have tried another interesting point, I have
tried that
the sizeof of Base is 1 byte in Visual Stduio. I am confused
what is the 1
byte consuming? It has no data members. :-)
The `sizeof' operator never yields 0, even for an empty class.
"sizeof Operator"
http://msdn2.microsoft.com/en-us/library/4s7x1k91.aspx
15.2.3 Replicated Base Classes [hier.replicated]
15.2.4 Virtual Base Classes [hier.vbase]
I have that book at hand. It covers general theories of muliple
inheritance,
ambiguity issue and how to use virtual base class to solve
ambiguity issue.
But seems Bjarne's logics are based on ambiguity issue arises
from different
data members (this is why we need to use virtual base class to
make a single
copy of data member). Again, my classes does not have data
members -- Bjarne
does not covers this situation, and seems my sample beyond his
book. :-)
It doesn't matter whether class contains any members or not.
Language rules don't change magically in presence of class
members. In the book, in order to make the case more apparent
Stroustrup uses class memebrs. He could use a cast to base as
well.
Alex
- Follow-Ups:
- Re: CreateInstance
- From: Alex Blekhman
- Re: CreateInstance
- References:
- Re: CreateInstance
- From: Igor Tandetnik
- Re: CreateInstance
- From: George
- Re: CreateInstance
- From: Igor Tandetnik
- Re: CreateInstance
- From: George
- Re: CreateInstance
- From: Igor Tandetnik
- Re: CreateInstance
- From: George
- Re: CreateInstance
- From: Igor Tandetnik
- Re: CreateInstance
- From: Ben Voigt [C++ MVP]
- Re: CreateInstance
- From: George
- Re: CreateInstance
- From: Alex Blekhman
- Re: CreateInstance
- From: George
- Re: CreateInstance
- From: Alex Blekhman
- Re: CreateInstance
- Prev by Date: Re: What does this line do?
- Next by Date: Re: compile error about destructor
- Previous by thread: Re: CreateInstance
- Next by thread: Re: CreateInstance
- Index(es):
Relevant Pages
|