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
Java static and dynamic types
A downcast can change the dynamic type of an object.
Why is this statement false? Is that because, there aren't static and dynamic types in Java?
Moreover, what is the static type and dynamic types of an object?

codemonkey
- 331
- 1
- 4
- 16
0
votes
1 answer
Downcast error in Xcode 7
In xcode 6, this code worked fine, but in Xcode 7GM, I am getting an error that states:
Downcast from ‘[UILocalNotification]? to ‘[UILocalNotification]’ only unwraps optionals; did you mean to use ‘!’?
The error occurs for the line where I have…

James
- 15
- 6
0
votes
2 answers
Trying to understand how the casting/conversion is done by compiler,e.g., when cast from float to int
When a float is casted to int, how this casting is implemented by compiler.
Does compiler masks some part of memory of float variable i.e., which part of memory is plunked by compiler to pass the remaining to int variable.
I guess the answer to…

saurabh
- 169
- 8
0
votes
1 answer
F# Downcasting Slow?
I have a situation where I need to downcast twice in one procedure using :?>. I have a custom EventArgs class (which inherits System.EventArgs), and an instance of an abstract class within that custom EventArgs. Upon receiving the event, I need to…

user3685285
- 6,066
- 13
- 54
- 95
0
votes
1 answer
Downcasting UICollectionReusableView to subclass fails
I created a subclass of UICollectionReusableView. Then in the function
collectionViewTableLayoutManager(manager: collectionView: headerViewForRow row: indexPath: )
I am trying to dequeue a view and cast it to the subclass.
Here's the start of the…

tangobango
- 381
- 1
- 4
- 17
0
votes
3 answers
Why downcast and then assign to base-class in C++?
I have stumbled upon the following code structure and I'm wondering whether this is intentional or just poor understanding of casting mechanisms:
struct AbstractBase{
virtual void doThis(){
//Basic implementation here.
};
virtual…

Gösta
- 21
- 1
- 7
0
votes
2 answers
Downcasting, Inheritance. Variable cannot be resolved or is not a field
I have a homework to do and I've got some problems with downcasting. Here are my three classes.
import java.util.LinkedList;
public class Bank {
LinkedList ListOfClients = new LinkedList();
public void addClient(Client…

buksio
- 1
- 1
0
votes
1 answer
Best practice when accesessing derived classes in a QList
I have a base model where I have implemented the virtual members of QAbstractItemModel. I then use my base model in my project as needed by deriving new classes with specifics.
class BaseModel : public QAbstractItemModel{
public:
...
…

RushK
- 525
- 1
- 5
- 13
0
votes
2 answers
Invalid initialization error while upcasting and downcasting an object
Consider the following code:
#include
#include
class Parent
{
public:
virtual void foo() const{};
};
class Child_A: public virtual Parent
{
};
void downcast( const Child_A& aa)
{
}
void upcast( const Parent& pp )
{
…

Eliad
- 894
- 6
- 20
0
votes
1 answer
Downcasting "folderID = folder.folderID as Int" crashes in release version of iOS app, but not in the debug version. Is it dangerous to use?
I decided today to upload my iOS8 app to iTunes Connect to try out TestFlight.
That worked fine, until I tapped on one of the tableviews and the app crashed. After half a day figuring out how to debug a released app, I finally was able to pinpoint…

Henk-Martijn
- 2,024
- 21
- 25
0
votes
1 answer
Infer rdf type of individual from owl domain of its property
I am studying the inference in OWL, currently the downcast of an individual type from its property domain. I've constructed the following example ontology:
@prefix : .
@prefix owl:…

igor.br
- 29
- 7
0
votes
1 answer
Cast Object to Subclass in PHP
I'm trying to extend the SimpleXMLElement class to provide a mechanism to merge sub XML string or other SimpleXMLElement into my SimpleXMLElement, code for that is based on code written by Carlos C Soto in an answer to the question "PHP - SimpleXML…

Pascal Heidmann
- 13
- 3
0
votes
3 answers
C# Upcasting / Polymorphism Issue
I believe this question is fairly basic but I am having trouble finding an answer to this question. In C# let's say I have 3 classes: A, B, C
B derives from A
C derives from B
Now, if I wanted a list or array of objects of type class A but wanted…

Brad Mash
- 69
- 6
0
votes
2 answers
Swift Downcasting AnyObject (Float) to String
I'm currently working with some dummy data, before I start using an actual API. But I'm having some problems filling one of my labels, with a number, that needs a symbol added to it.
Rather than explaining everything, here's a screencap of an early…

MLyck
- 4,959
- 13
- 43
- 74
0
votes
0 answers
How do I type check, without including subclasses?
I want to know if an object is a type without including its subtypes. For example:
class Dog {
}
class Labrador: Dog {
}
//I want this to be false
if pet is Dog {
}

Andrew
- 7,693
- 11
- 43
- 81