基类指针赋值兼容规则
来源:互联网 发布:决策与判断知乎 编辑:程序博客网 时间:2024/06/05 16:50
/*
赋值兼容规则
作者:qpz
*/
#include <iostream>
#include <vector>
using namespace std;
class Base{
private:
int x;
int y;
public:
Base(int x,int y)
{
this->x=x;
this->y=y;
}
};
class Derived:public Base{
private:
int z;
public:
Derived(int z):Base(z-1,z+1)
{
this->z=z;
}
};
int main(void)
{
//Derived *p=new Base(2,1);//因为派生类指针映射范围大
Base *p=new Derived(1);
delete p;
return 0;
}
0 0
- 基类指针赋值兼容规则
- 强制类型转换为基类指针与赋值兼容规则下转换为基类指针的比较
- 赋值兼容规则
- 赋值兼容规则
- 赋值兼容规则
- 赋值兼容规则
- 赋值兼容规则
- c++赋值兼容规则
- C++的赋值兼容规则
- 【总结】C++基类与派生类的赋值兼容规则
- [c++]基类对象作为函数参数(赋值兼容规则)
- C++赋值兼容规则和类类型转换注意事项之一
- C++赋值兼容规则和多态
- 赋值兼容规则及虚函数
- c++学习之赋值兼容规则
- 钻石继承、虚基类、赋值兼容规则
- 同名隐藏与赋值兼容规则
- C++ 同名隐藏和赋值兼容规则
- ZooKeeper 笔记
- HTML页面上面固定下面滚动的实现
- c#linkedlist list的区别
- 约瑟夫环的队列实现
- JAVA中字符串比较equals()和equalsIgnoreCase()的区别
- 基类指针赋值兼容规则
- function template
- vector function trmplate
- 冒泡排序,直接选择排序,插入排序实现
- Construct Binary Tree from Inorder and Postorder Traversal
- 最大公约数,最小公倍数
- 关于内存对齐的探索
- 利用CCS和DM814x Flash烧写工具烧写Nand Flash
- N*N矩阵的旋转 不开辟新空间