All Questions
Tagged with inheritance virtual
579
questions
-1
votes
0
answers
34
views
invalid covariant return type for [duplicate]
Consider the following example, which is some part of the bigger codebase, in the getInstance() if I dont return a pointer to the derived class, i.e., just void or int or a different type, the ...
0
votes
1
answer
83
views
Using keyword with virtual inheritance in cpp
I want to resolve an inheritance problem of my Paladin class. Here is a resume of the inheritance between my classes :
class Peasant
{
virtual int attack();
}
class Knight : virtual public ...
2
votes
1
answer
94
views
c++ calling operator()() in derived class not working
I have a abstract base class having operator()(), operator and virtual operator()(...) methods. In derived class i am overriding the virtual method but i cannot call the opearator()() method. And i ...
1
vote
2
answers
118
views
c++ how can i access virtual method in a template class which will be overriden in derived class
I have a templated Base class with 2 virtual methods begin() and end().
I also have Derived1 class derived from Base class, and
Derived2 class derived from Derived1 class.
I am overriding method begin(...
0
votes
1
answer
63
views
C++ virtual template member function [duplicate]
#include <iostream>
class Data_X {
public:
Data_X(int x): x(x) {}
int getData() {
return x;
}
private:
int x;
};
class parent {
public:
template <typename T>
T* ...
-1
votes
2
answers
66
views
class instance (object) dot namespace double colon non static function [duplicate]
#include <iostream>
using namespace std;
namespace xyz {
class Base {
public:
bool configure (double a) {
cout << "Do nothing. a is currently equal to: &...
1
vote
1
answer
166
views
If a derived class has a method with a signature that is exactly the same as signature from a method in the base class, does it generate a vtable?
I recently watched a YouTube video from "Low Level Learning" where, at 03:38, it was mentioned that "functions with the same signature in the derived class are virtual in the parent by ...
0
votes
0
answers
74
views
Calling virtual function in a parent/inherited class
I have the following code in C++:
#include <iostream>
using namespace std ;
class A{
public:
void m1(){
cout << "A" << endl;
}
virtual void m2(){
cout <&...
0
votes
1
answer
107
views
Is there any way to approach the same functionality without "virtual" keyword in swift
Absence of "virtual" keyword and consequences in swift.
Hello everyone.
Because there is no "virtual" keyword I don't know that how can I create a subclass which has 2 methods with ...
0
votes
1
answer
43
views
C++ OOP overloading ostream problem at printing
This is my code:
#include <iostream>
#include <cstring>
using namespace std;
class ObiectCosmic{
protected:
char* nume;
float raza;
float masa;
public:
...
0
votes
0
answers
58
views
Method of Class derived from template class "shadows" base class method
I have defined a class "B" inheriting from a Base abstract class "A" which has a pure virtual method:
A.h
template <class T>
class A{
public:
virtual bool doSomething(...
0
votes
1
answer
46
views
Method overloading & Method Hiding in C++
Why does the compiler not throw error in main() for p->f4(); line.
As per my understanding class B hides f4() and should throw error
class A
{
public:
void f1(){}
virtual void ...
5
votes
0
answers
142
views
Virtual inheritance and class function pointer size
I have the following code, I am using MSVC:
template <typename T>
void CanMock() {
class SimpleType {};
static_assert(sizeof(void(SimpleType::*)()) == sizeof(void(T::*)()),
&...
1
vote
1
answer
63
views
virtual method overridden issue with unique_ptr move semantics [duplicate]
It looks like in below code snippet virtual method overridden is not happening with Adapter object and both Target and Adapter object is showing same output.
#include <iostream>
#include ...
0
votes
3
answers
144
views
Virtual function in Inheritance in C++
**Read the below mention code **
#include<iostream>
using namespace std;
class FR
{
public :
virtual int fun()
{
cout<<"In FR Class "<<endl;
}
int ...