object-slicing
Unhandled Exception due to Class slicing
I\'m getting an unhandled exception reading location 0x00000008 (reading NULL value) on the noted line below, relevant methods leading up to the error are included (continued below examples):[详细]
2023-03-24 03:06 分类:问答how to over come the issue of object slicing in c++ [closed]
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari[详细]
2023-03-23 18:23 分类:问答Return reference to sliced object (supertype)
Consider the following classes: class Coord { public: double _x, _y; Coord(double x, double y) { _x = x; _y = y;[详细]
2023-03-06 17:51 分类:问答Why do virtual functions need to be passed with a pointer and not by value(of the object)?
I think I understand the concept开发者_如何学Python of virtual methods and vtables, but I don\'t understand why there is a difference between passing the object as a pointer(or reference) and passing[详细]
2023-03-01 03:22 分类:问答Object Slicing in c++
class Base { int iBase; public: virtual void display() { cout<<\"I am a Base Class\"<<endl; }开发者_高级运维[详细]
2023-02-06 21:44 分类:问答Why isn't this method call virtual like I was expecting?
I want to ask what happen, when I use virtual functions without pointers ? for example: #include <iostream>[详细]
2023-01-13 21:37 分类:问答Is the reason fot the error object slicing?
g++ -std=gnu++0x main.cpp In file included from main.cpp:6:0: CustArray.h: In constructor \'CustArray::CustArray()\':[详细]
2023-01-08 04:42 分类:问答C++ polymorphism and slicing
The following code, prints out Derived Base Base But I need every Derived object put into User::items, call its own print function, but not the base class one. Can I achieve that without using poin[详细]
2022-12-25 09:13 分类:问答Avoid slicing of exception types (C++)
I am designing an exception hierarchy in C++ for my library. The \"hierarchy\" is 4 classes derived from std::runtime_error. I would like to avoid the slicing problem for the exception classes so made[详细]
2022-12-13 20:03 分类:问答Is it possible for slicing to occur with Smart Pointers?
If I understand slicing correctly I don\'t think this could happen with pointers or smart pointers. For example, if you had:[详细]
2022-12-08 05:59 分类:问答