Downcasting permits an object of a superclass type to be treated as an object of any subclass type.
Questions tagged [downcast]
589 questions
0
votes
1 answer
C++ A polymorphic class, virtual function and casting for performance
I have the following classes:
class State
{
protected:
Vec3D accel;
Vec3D gyro;
Vec3D gps;
float reward;
public:
boost::ptr_vector actions;
...
virtual bool isTerm();
}
class guState : public State
{
…

Ælex
- 14,432
- 20
- 88
- 129
0
votes
2 answers
How to downcast shared_ptr without std::static_pointer_cast in C++?
we use EASTL and I can't use std::static_pointer_cast.
I receive a pointer to base class in my function and don't know, how to correctly cast it:
switch (command.code)
{
..
case CommandCode::firstCase:
…

Lukas Salich
- 959
- 2
- 12
- 30
0
votes
4 answers
Downcasting from Object to Integer Runtime Error: java.lang.ClassCastException
Run time exception-- java.lang.ClassCastingException...
Integer intArr[] = new Integer[arrList.size()];
ArrayList arrList =new ArrayList();
intArr=(Integer[])arrList.toArray(); // returns Object class which is downcaste to Integer;
I…

Bharat Gaikwad
- 530
- 2
- 5
- 16
0
votes
1 answer
Downcasting Objects to references in java
I am working on an assignment and don't understand downcasting.
For example, class Reference.java and I'm in a method that passes an object in. If that object is of type (not sure if that is the right word) then create a new Reference object. This…

Anthony
- 51
- 6
0
votes
0 answers
method for downcasting to child class with type deduction
The crux of the issue is I want to create a vector of base pointers to reference children objects. However I'm having issues accessing the methods of the children. I've seen examples of downcasting online but I don't feel it's the best thing for me…

hdamlaj
- 51
- 4
0
votes
1 answer
How can I cast Gtk::Widget to GtK::ScrolledWindow on gtkmm?
On the code bellow I am setting ScrolledWindows on a grid container and then setting their properties in a loop, because I want to put TextViews on the grid. I do not want to use TreeView because it will be ackward to put long or moderate texts…

jeferson lemos
- 21
- 3
0
votes
2 answers
Can I apply downcast to an iterator?
I need to know if I am sending a template class the right type of containers by applying downcast.
// C++ program to demonstrate input iterator
#include
#include
#include
using namespace std;
int main()
{
…

Kamil Kaya
- 47
- 5
0
votes
0 answers
does PHP support Downcasting?
i was searching in the internet for a way to do downcasting in PHP, but i couldn't find any thing useful, does PHP support it? if not, is there a way to achieve that?

Malek Alhourani
- 39
- 1
- 6
0
votes
2 answers
Handling interactions between different derived class objects
I have a program where I have a vector of pointers to a base class where I store instances of multiple different derived classes. All these objects interact with each other in different ways depending on their type and I'd like to implement these…

Petri Hirvonen
- 59
- 6
0
votes
1 answer
Can I down-cast a class forcing it to lose the original constructor/s?
run the code below on dartpad
class Foo {
const Foo(this.message);
final String message;
}
class Bar extends Foo {
const Bar(String message, this.another,) : super(message);
final String another;
}
void main() {
const Foo _foo =…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
0
votes
0 answers
Connect SwipeCellKit to custom cell with override - Swift
When I load my UITableViewController that populates with custom (xib) cells, my app crashes with error:
Could not cast value of type 'SwipeCellKit.SwipeTableViewCell' to 'GreenHarvestAlpha.ListCell'.
Yet, ListCell has the grandparent class…

eyesplice17
- 231
- 2
- 6
0
votes
1 answer
c# How to put all dictionary into an object of derived type from Dictionary?
class XDictionary : Dictionary
{
}
Dictionary d = new Dictionary
{
{ "x", "xx" },
{ "y", "yy" },
{ "z", "zz" }
};
…
0
votes
2 answers
compile time selection of a specific method, disguised as an operator
I have a class like this one:
struct Base
{
void aa(int n) const {
std::cout << "aa() " << field*n << std::endl;
}
void bb(int n) const {
std::cout << "bb() " << field*n*2 << std::endl;
}
int field = 2;
};
I…

L. Bruce
- 170
- 7
0
votes
1 answer
How to prevent information loss when downcasting floats and integers using pandas.to_numeric() in python
In order to save memory, I started looking into downcasting numeric column types in pandas.
In the quest of saving memory, I would like to convert object columns to e.g. float32 or float16 instead of the automatic standard float64, or int32, int16,…

Andreas L.
- 3,239
- 5
- 26
- 65
0
votes
0 answers
How can I make sure my Segue passes some value and it doesn't get out of bound error?
I am new to coding. I'm trying to create a notes app.
My code:
import UIKit
class TableViewController: UITableViewController, NoteViewDelegate {
var arrNotes = [[String:String]]()
var selectedIndex = -1
override func viewDidLoad() {
…

Manan Jain
- 27
- 5