In OOP (Object Oriented Programming), a base class that cannot be instantiated because some of its declared methods lack a definition, which is intended to be provided by derived classes. The term may have more specific or slightly different meaning according to the particular computer language involved.
Questions tagged [abstract-base-class]
109 questions
0
votes
1 answer
Acessing overloaded function from an Abstract Base class
I know this question has been asked before in some form. But I am still confused.
Suppose I have two classes.
class A{
public:
void foo(int a, int b);
protected:
virtual void foo(int a) = 0;
}
class B : public class A{
void foo(int a);
}
Now if…

Ayush Pandey
- 565
- 6
- 19
0
votes
1 answer
Use a python class as a toolkit?
I'm not sure what the proper way of doing this is but I have the following code:
class ToolKit(object):
def printname(self):
print self.name
class Test(ToolKit):
def __init__(self):
self.name = "Test"
b =…

Max Smith
- 925
- 1
- 14
- 25
0
votes
1 answer
Mock call to protected method of base abstract class from derived class public method using Microsoft.fakes
I am trying to write unit test for the code shown below using Microsoft.Fakes.
As new to Microsoft.Fakes i am facing difficulty in mocking the call to abstract base class protected functional method
My base class:
public abstract class…

SRS
- 1
- 2
0
votes
1 answer
Why are __sub__ and __rsub__ implemented and, in this way, for numbers.Complex
I was looking at the implementation of Complex in the numbers module and noticed __sub__ and __rsub__s implementation that looked like this:
def __sub__(self, other):
""" self - other """
return self + -other
def __rsub__(self, other):
…

user6774416
- 756
- 5
- 18
0
votes
1 answer
use derived class object in base class
I have a base class which contain helper method, and I have some derived classes which contain some virtual methods.
so, I want to know how can I use the derived class object in the base classes virtual methods?
derived class
class myclass…

Non_k
- 47
- 1
- 11
0
votes
2 answers
Array of pointers to base class: how to call unique derived class method
Been Googling for a while on this one, but can't seem to find a clear answer.
How do I call the unscramble() method in the following example?
Thanks. :^)
class Food {
public:
Food(string _t):type(_t);
virtual void eat() = 0;
private:
…

kmiklas
- 13,085
- 22
- 67
- 103
0
votes
1 answer
Python 2.7 -- Calling an Abstract Base Class' method from an Instance
I am searching for the proper way to call an abstract base class' method from an instance of a class that is registered as a subclass of the ABC. This is some very basic test code to first figure out how to make this work. This is where I am…
user4766915
0
votes
0 answers
Calling the abstract base class constructor
The library has a class of neural network. If I create one network - all work fine, but when I create two or more networks - one of them stops learning. After several hours of searching the error I find that if I call base constructor after…

senior-zero
- 21
- 1
0
votes
1 answer
C++ Design issues: Map with various abstract base classes
I'm facing design problems and could do with some external input. I am trying to avoid abstract base class casting (Since I've heard that's bad).
The issues are down to this structure:
class entity... (base with pure virtual functions)
class…

SharkBytes
- 211
- 4
- 18
0
votes
2 answers
Is an Abstract Class the same thing as a Base Class?
Is an Abstract Class the same thing as a Base Class?
I occasionally see the term Base Class, but when I look up what it means, I tend to see "Abstract Class" thrown around.
Are they just two words that mean basically the same thing?

user2690449
- 53
- 1
- 5
0
votes
1 answer
STL map and pure virtual base class
I have not used C++ in a long time. I'm trying to display some polymorphic behavior:
class func {
public:
virtual void print() = 0;
};
class func1 : public func {
public:
void print () { cout << "FUNC 1" << endl; };
};
class func2…

Squall Leohart
- 657
- 2
- 8
- 20
0
votes
1 answer
Adding a numeric type between Real and Rational, and supporting the type's functionality for Rational numbers
Python offers a set of abstract base classes for types of numbers. These start with Number, of which Complex is a subclass, and so on through Real, Rational and Integral. Since each is a subclass of the last, each supports the special functionality…

Hammerite
- 21,755
- 6
- 70
- 91
0
votes
1 answer
‘class shape’ has no member named ‘info’ but adding one doesn't work either
I'm trying to get some code to compile (This code) but when I comment out line 25:
virtual void info()=0;
it doesn't compile:
shape.cpp: In function ‘int main()’:
shape.cpp:345:11: error: ‘class shape’ has no member named ‘info’
…

Jamie Twells
- 1,924
- 4
- 26
- 56
0
votes
3 answers
For a derived class with a constructor that takes a base class pointer, how do I refer to the base class pointer?
I'm working on an assignment on abstract base classes for shapes. For the last section we need to write a class which is a general 3D version of any of the prior 2D shapes eg. square.
So as you can see from my code below, its constructor takes a…

fred
- 23
- 1
- 5
0
votes
2 answers
Abstract base class that defines a pure virtual function with a void* param. Derived class matching param is a pointer to some type
Revised, actual Base And Derived Class I am working with plus the function that instantiates it and uses the non virtual function call
ShaderClass.h
#ifndef SHADERCLASS_H
#define SHADERCLASS_H
#include
#include…

Francis Cugler
- 7,788
- 2
- 28
- 59