Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
46 views

The OpenCL API has one object which is sort of a "kitchen sink" for a lot of stuff: The program (with handle type cl_program). It can hold: A textual program source ( ...
einpoklum's user avatar
  • 137k
-1 votes
1 answer
65 views

I’m really confused about what polymorphism in OOP actually means. Everyone explains it differently, and I’m not sure which definition is correct: In some places, polymorphism is explained as dynamic ...
Ado's user avatar
  • 55
2 votes
2 answers
90 views

[defns.dynamic.type] reads ⟨glvalue⟩ type of the most derived object to which the glvalue refers from which I understand that given struct B { virtual ~B() = default; }; struct D : B {}; std::...
Enlico's user avatar
  • 30.3k
0 votes
1 answer
150 views

Can we achieve runtime polymorphism(method overriding) without virtual function in C++ I think that since it is runtime it should only be possible through pointers using virtual functions but we can ...
Abhishek's user avatar
0 votes
1 answer
122 views

I know the following Compiler constructs a virtual table for every class containing at least one virtual function. It also adds a pointer(v_ptr) to the base class(supposing it has virtual function(s)) ...
dRIFT sPEED's user avatar
0 votes
1 answer
51 views

I have a class A -> class B (child of A) -> class C (child of B) and class A -> class D. How can I write a function that return objects from class B and class D, example below. How to ...
Mahesh's user avatar
  • 1
1 vote
1 answer
137 views

There is a class Base which has a function add that inputs integers from the users and prints their sum. There's another class called Derived which publicly inherits the Base class and it also has a ...
Tanishq Kohli's user avatar
-1 votes
2 answers
110 views

I have three classes called Animal, Cat and Dog where Cat and Dog inherit from Animal: public class Animal { public void Talk() { Console.WriteLine("Parent"); } } public ...
IMm0rtal's user avatar
  • 111
0 votes
3 answers
153 views

**Read the below mention code ** #include<iostream> using namespace std; class FR { public : virtual int fun() { cout<<"In FR Class "<<endl; } int ...
Jigar Patel's user avatar
-1 votes
1 answer
180 views

I was reading about function overriding and run-time polymorphism online. While reading I found an example of function overriding on programiz where following example was given : // C++ program to ...
Shailav Malik's user avatar
0 votes
1 answer
64 views

Considering a struct point struct point{ int x; int y; int z; } and a class object class object{ public: std::vector<point> points; int dimension_count; ...
Kevin's user avatar
  • 310
0 votes
1 answer
394 views

I know benchmarking is a very delicate subject and simple, not-well-thought-out benchmarks are mostly meaningless for performance comparisons, but what I have right now is actually a pretty small and ...
meguli's user avatar
  • 1,576
0 votes
2 answers
869 views

I was studying OOP from here. It says that runtime polymorphism is possible in C++ using data members. Now,consider this code:- #include <iostream> #include <string> class Animal { ...
coder_01's user avatar
1 vote
1 answer
155 views

late-binding or runtime-polymorphism needs 2 things: a base pointer and a virtual method. class FrameWorkClassBase { public: virtual void method() = 0; }; class FrameWorkClassDerived: public ...
Self's user avatar
  • 194
0 votes
1 answer
346 views

I have created a base class Polygon and declared two data members - height and width as public. Also a virtual function - calculateArea(). Then the two derived classes rectangle and triangle have a ...
Adnan's user avatar
  • 59
0 votes
0 answers
161 views

The problem is that in main function pointer to abstract class list calls operator+ of this class. But how can I call overloaded operators from child classes (queue and stack) with pointer to parent ...
nameses's user avatar
5 votes
3 answers
793 views

The main problem is simple, really. Given a base (more abstract) class and multiple derived ones that need to interact with each other, how do you go about doing it? To give a more concrete example, ...
Andrei-Info's user avatar
-1 votes
1 answer
241 views

I created the following program to implement Run-time Polymorphism in C++ /* Consider a book shop which sells both books and video-tapes. Create a class know as media that storea the title and price ...
Subhan Raj's user avatar
0 votes
1 answer
1k views

So I have been programming in C++ for a while now, and I was told that using a dynamic cast to cast a pointer of an abstract class pointer to a different concrete class pointer was bad practice. Shape*...
Henry Keskitalo's user avatar
1 vote
0 answers
40 views

In the following code a public function has overriden a private virtual function in base class ob->hello() shall call hello() in derived class which is public. why do i still see an error that ...
pinky's user avatar
  • 11
4 votes
1 answer
3k views

I have a class A as a base class of class B. I have called the non-virtual function, abc(), within my virtual function, xyz(), as mentioned below. Due to run-time polymorphism, B:xyz is called – I ...
Sumaiya A's user avatar
  • 147
0 votes
0 answers
73 views

Is it possible to upcast an Rc<dyn Foo>? If not, why not? use std::rc::Rc; trait Bar {} trait Foo: Bar {} fn upcast(this: Rc<dyn Foo>) -> Rc<dyn Bar> { this } results in ...
dspyz's user avatar
  • 5,604
11 votes
2 answers
5k views

When one already knows all the finite number of types involved in some code which needs dynamic polymorphism, using enum can be better for performances compared to using Box since the latter uses ...
nyarlathotep108's user avatar
1 vote
2 answers
186 views

#include <iostream> class A { public: virtual ~A() = default; virtual void foo(void) = 0; }; class B : public A { private: int x; public: B(int a) :...
user3224083's user avatar
-2 votes
1 answer
116 views

A multimedia file may have data of different date types such as uint8_t, int16_t, float, etc. Below three examples show file content with the first byte indicate data type: 1st File: 0,<uint8 data&...
cmere's user avatar
  • 1
0 votes
1 answer
108 views

I have the following classes in my program: class base { public: int bval; base() { bval = 1; } }; class deri: public base { int dval; public: deri() { dval = 2; ...
Kashinath Patekar's user avatar
0 votes
1 answer
36 views

As you'd expect, I've arrived at a question I can't answer and I can only guess. Runtime polymorphism is the goal, using the virtual mechanism, but the result I'm getting is as if I called the method ...
Glenn Storm's user avatar
0 votes
3 answers
392 views

I am trying to understand dynamic method dispatch. class A { int i=10; void callme() { System.out.println("Inside A's callme method"); } } class B extends A { int j=20; void callme() { ...
Nithin Gowda's user avatar
0 votes
1 answer
134 views

Background I am writing an application which utilizes USB devices. This includes device discovery of the USB devices my application can use, based on USB vendor id and product id. However these ...
Superlokkus's user avatar
  • 5,159
1 vote
0 answers
133 views

Below is my DTO in C#.Net public class Movie { public int Id { get; set;} public IEnumerable<Blog> Blogs {get; set;} } public class Blog { public int Id { get; set;} } public class BlogCat1 ...
Kgn-web's user avatar
  • 7,645
-1 votes
1 answer
109 views

I am studying run time polymorphism, I find one example like this class Bike { void run() { System.out.println("running"); } } class Splender extends Bike { void run(){ ...
dev_swat's user avatar
  • 1,344
1 vote
2 answers
802 views

Before I ask my question, let me to explain my understanding and opinion. By only Overriding we can't achieve polymorphism unless there is upcasting. And as it can only seen at runtime people might ...
PraveenKumar Lalasangi's user avatar
2 votes
3 answers
487 views

I have 3 classes where one is the super class and other two are sub classes. They have print() method common in them. While calling print() methods from main() I have upcasted the objects to super ...
Vaibhav More's user avatar
  • 1,112
3 votes
1 answer
2k views

How do I define a HashMap supporting both String and &str in its key and content? I tried the following: fn mapping<T: Into<String>>() -> HashMap<T, T> { let mut map: ...
Jimmy Chu's user avatar
  • 1,012
5 votes
1 answer
708 views

I am reading about the implementation of late binding polymorphism in C++ and I learned about virtual tables and virtual pointers. Then I searched on the C++ standard (ISO/IEC 14882:2011) to get ...
nowox's user avatar
  • 29.7k
0 votes
2 answers
677 views

class Base { public: virtual void func1() { std::cout<<"Base func1"<<std::endl; } //virtual destructor }; class Derived : public Base { ...
Naresh's user avatar
  • 155
0 votes
1 answer
138 views

Due to Dynamic Method Dispatch, on creating an object using Superclass reference and calling a method through this object that has been overridden in the subclass, the overridden method in subclass ...
DataExtractor's user avatar
1 vote
2 answers
267 views

I present to you this code riddle: Using this compiler: user@bruh:~/test$ g++ --version g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free ...
MK-Ultra-'s user avatar
0 votes
2 answers
156 views

Let's say I am trying to implement some math vector class. As vector interface will be used in multiple places: array based vector, matrices return columns and rows as vector interface objects and ...
gan gan's user avatar
-1 votes
2 answers
40 views

Please don't be stuck in spelling mistakes. I didn't understand why Prof' saluer function is working with Prof arguments in the screen output. Code output: Mes hommages pour ma / mon collègue ...
Batuhan D.'s user avatar
0 votes
1 answer
87 views

Is it possible in java to inherit some methods from the base class, but not all of them? Just to be clear, i will show you what I mean: Suppose we have the base class Visitor public abstract class ...
Andrew's user avatar
  • 104
0 votes
2 answers
325 views

Consider a superclass: class superclass { public void fun() {.....} } and it's subclass: class subclass extends superclass { public void fun(){.......} public static void main() { ...
Himanshu's user avatar
8 votes
5 answers
2k views

Does runtime polymorphism always happen with method overriding, or does it happen only if method is called after assigning sub class object to super class variable, during method overriding? class A { ...
Lemmy's user avatar
  • 223
0 votes
1 answer
170 views

Upcasting in OOPS makes runtime polymorphism possible by overriding methods of parent and child classes. Can downcasting in OOPS also be run-time polymorphic in any way?
Kamalapriya Subramanian's user avatar
0 votes
1 answer
33 views

From what I learned so far, there are two kinds of polymorphism, compile-time, and runtime. In compile-time, the polymorphed function or operator is resolved by compiler, while in runtime, its ...
Shiladitya Bose's user avatar
1 vote
0 answers
663 views

I learned the difference between static and run-time polymorphism and since then I've been reading a lot of stuff on it. Plus, since I found out that implementing a static polymorphic interface (in a ...
bactria's user avatar
  • 11
-3 votes
2 answers
104 views

Which one is better and why ? a) List<String> list = new ArrayList<>(); b) ArrayList<String> list = new ArrayList<>();
Rahul Badiger's user avatar
1 vote
1 answer
142 views

How does polymorphism work, under the hood, in python? In python, if I have some function e.g. def f(x): return x + 2*x + 3*x + 4*x + 5*x + 6*x then according to dis.dis(f) python translates ...
benjimin's user avatar
  • 5,092
0 votes
4 answers
983 views

I know that,No matter what the actual object is,that the reference variable refers to,The methods i can call on a reference is dependent on the declared type of the variable (in line 15 of code).I ...
skm's user avatar
  • 25
0 votes
2 answers
6k views

Why reference variable of child class can't point to object of parent? i.e Child obj = new Parent(); However we can do vice versa Kindly answer with memory view (heap)
ShahEryar Ahmed's user avatar