python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Why casting is not possible from child to parent
I have a class Animal which has one child Dog.
class Animal {
public void makeSound() {
System.out.println("Animal sound");
}
}
class Dog extends Animal {
@Override
...
User_214534
Votes: 0
Answers: 1
TypeError: "method is not a function" error when downcasting to a subclass - discrord.js
Please, don't mind my grammar and code mistakes because I am a self-taught coder
I am developing a multi-purpose Discord bot with NodeJS using discord.js and typescript libraries.
When creating the ...
DeMineArchiver
Votes: 0
Answers: 0
Downcast trait to generic type
I have the following 2 traits: Org, Capability.
#![feature(specialization)]
trait Org {}
struct OrgV1 {}
impl Org for OrgV1 {...}
struct OrgV2 {}
impl Org for OrgV2 {...}
trait Capability {}
str...
Aibek
Votes: 0
Answers: 1
Does this downcasting lead to undefined behavior?
Given this sample:
class Base
{
public:
void foo() {};
};
class Derived : public Base
{
};
int main()
{
Base b;
Derived* d = static_cast<Derived*>...
user18487620
Votes: 0
Answers: 1