Question about heritance and other aspects.
Question
1.--------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
class B
{
public:
int i;
B()
{}
};
class A
{
public:
A(B& b1)
{
b1.i=0;
}
};
class C : public A
{
B b;
public:
C() : A(b)
{}
};
As the code above, b is a private object for class C. Why I can revise b as
a reference in constructor of class A.
As I know, even class C herites from class A, A can not revise any private
properties in C, is that right?
Question
2.--------------------------------------------------------------------------------------------------------------------------------------------
class A
{
public:
A()
{}
friend ostream& operator << (ostream& os,A& ac)
{}
};
If I remove keyword "friend", operator << will be seen as a bit operator
instead of a stream operator, why? (I think If I add keyword "friend" before
the function
declaration, it just means this function can revise private properties in
class A, the keyword can not effect whether "<<" is a bit operator or not.)
Question
3.--------------------------------------------------------------------------------------------------------------------------------------------
Sorry,I write ASM in C++ newsgroup, but it's related with my question.
Coorder STRUCT
X WORD ?
Y WORD ?
Coorder ENDS
m_order Coorder <0,0>
It's about storage space in C++ thinking from assembly language (IA 32
instruction set)
ASM "STRUCT" itself(I mean declaration) will not be stored in storage space,
but for ASM "STRUCT Variant"(m_order) it will live in storage space at
runtime. (I don't know whether it's right.)
this description let me think about "class" in C++. Can I say: the
declaration of a "class" will not be stored in storage space? if what I said
is right, how C++ compiler deals with inline function
if "class" is not in storage space.
Thank you for your help.