c++重载和继承,调用new方法
C++ overloading and inheritance, call new method
我有一个类a:
class A {
public:
do_end(){
finish...
}
do_something(){
stuff is done...
do_end();
}
}
和B类,B类派生自A:
class B :public A {
public:
do_end(){
finish differently...
}
}
现在当我这样做的时候:
B b;
b.do_something();
调用A的do_end()方法。我如何使用的do_something()的A,但有它调用方法do_end()的B?有办法吗?
谢谢
在类A中定义函数do_end为具有函数说明符virtual
virtual SomeType do_end(){
finish...
}
相关文章:
- 在不同的编译器版本中调用new[]和delete[]
- 通过传递外部指针或内部调用 new 构造的类,我可以在销毁时天真地删除这个指针吗?
- C++:光线追踪器导致内存不足错误 - 由于反复调用"new"?
- 在CUDA内核中调用new运算符
- 为什么智能指针不能在其构造函数中为我调用 new()?
- 如果我在 C++ 中调用 new,但堆内存不足,会发生什么情况
- 如何在多维数组上调用 new
- 运算符在C++中何时调用'new'构造函数
- 调用"new"以存储到shared_ptr的引用向量中
- 为什么连续调用new[]不会分配连续内存
- Java可以初始化类似C++的对象数组中的对象,而不必循环和调用new
- 如何为数组的类型调用 new 运算符
- 在条件调用new时调用delete
- c++重载和继承,调用new方法
- 在c++ 11中,如何调用new并为对象保留足够的内存?
- 调用'new'如何调用用户定义的放置分配函数?
- 在同一个vtkSmartPointer上调用new两次是不安全的吗?
- 当调用new函数时,返回地址值发生了什么?
- 在同一个for循环中多次调用new
- C++ 构造函数/析构函数调用 &对动态创建的数据调用"new"是否会删除旧数据?