由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ 请教: about the memory layout of the class inheritance
相关主题
C++中怎么传递std::hex这样的参数啊问一个有关iostream的问题
子类的assignment operator 怎么访问父类的private memberC++ template function一个问题
一个C++的概念问题呼唤大侠们,我实在不能实现C++泛型的精神。
为什么在overloading中,friend <<不能读取private值呢?C++ template question
再问两个C++问题C++ Q13: Input
请问这是什么错误呀输入输出流,stl,api精通各需要多长时间?
C++ template question with friend ostreamabout namespace
Why should i include .cpp instead of .hreturn Triangular_iterator( _beg_pos );意思
相关话题的讨论汇总
话题: class话题: int话题: c++话题: top
进入Programming版参与讨论
1 (共1页)
O*****l
发帖数: 13
1
请教这里的C++ guru们,谁能解释一下以下几种C++继承中的基类和继承类在内存中是什
么样的结构:
class A
{
int fieldA;
int func();
}
class B : class A
{
int fieldB;
int func();
}
1. inheritance without virtual functions
[This I know] the memory layout is as simple as: [fieldA fieldB]
2. inheritance with virtual functions
[Not quite clear] looks like in debugger memory [vtprA fieldA fieldB]
should there be a vtable pointer for B?
3. multiple inheritance if there is a class C:A and a class D:B, C
4. multiple inheritance with virtual
E*****7
发帖数: 128
2
#include
using namespace std;
class Top {
protected:
int x;
public:
Top(int n) { x = n; }
virtual ~Top() {}
friend ostream&
operator<<(ostream& os, const Top& t) {
return os << t.x;
}
};
class Left : virtual public Top {
protected:
int y;
public:
Left(int m, int n) : Top(m) { y = n; }
};
class Right : virtual public Top {
protected:
int z;
public:
Right(int m, int n) : Top(m) { z = n; }
};
class Bottom : public Left, public Right {
int w;
public:
Bottom(int
1 (共1页)
进入Programming版参与讨论
相关主题
return Triangular_iterator( _beg_pos );意思再问两个C++问题
请教C++程序中的Maze().exitMaze();请问这是什么错误呀
请问关于overloading <<C++ template question with friend ostream
Question about IIFWhy should i include .cpp instead of .h
C++中怎么传递std::hex这样的参数啊问一个有关iostream的问题
子类的assignment operator 怎么访问父类的private memberC++ template function一个问题
一个C++的概念问题呼唤大侠们,我实在不能实现C++泛型的精神。
为什么在overloading中,friend <<不能读取private值呢?C++ template question
相关话题的讨论汇总
话题: class话题: int话题: c++话题: top