Questions tagged [inheritance]
One of the four pillars of object-oriented programming (OOP), inheritance establishes a "is-a" relationship between objects. For example, a "Cat" object can be treated in code as any other "Animal" object because a "Cat" is-a "Animal".
306 questions
-1
votes
1
answer
111
views
Am I overusing classes and/or OOP features? [closed]
I have a very class heavy approach to writing C++ code, which I don't think is necessarily wrong. However, I often use classes without knowing if I actually need them, which I feel leads to making ...
0
votes
1
answer
100
views
Implementing safe custom exception [closed]
I was trying to come up with some design to subclass built-in exceptions.
For simplest case I used something like this:
...
9
votes
3
answers
609
views
Parsing SFV files to extract and store the hashes
Similar to the class for the RAR file, now a class to extract and store the hashes from SFV files.
Though this was considerably easier, there has been some code reorganisation: there is now an ...
5
votes
2
answers
324
views
ostream that counts and discards the characters written to it
The code below implements a class, CountingOStream, whose job is to
count the number of characters written to it while also discarding those
characters and ...
2
votes
0
answers
76
views
Classes for Config and logical operators
I have a spring cloud gateway application with this yml structure for request validation:
...
2
votes
0
answers
170
views
"Better" enumeration for C#
I've been looking to have "smarter" or "better" enum functionality in C#. There are a few GitHub/NuGet projects out there, but they seem to target newer versions of .NET and I ...
1
vote
1
answer
235
views
Python3 currency abstract class (without the permission to be instantiated directly)
I'm a newbie python developer who accidentally studied the concept of
Abstract classes
and I found it pretty much helpful to implement due to the SOLID principles.
At the very moment of testing and ...
2
votes
1
answer
101
views
Python 3.10+: an exploration of meta classes and subclasses through the lens of metric (SI) prefixes with subclass-able units and changeable bases
Problem Statement
From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes:
e.g.
Purpose
Name
Symbol
Factor
Name
...
0
votes
1
answer
275
views
Calling the base method from overriden method to add some functionality
I have a small Linked list program which I created for just brushing up the concepts.
Following is my Node class
...
1
vote
2
answers
95
views
Extend native `Array` instances
I need/want to extend created array instance, to add extra methods that i see as useful.
class.labels.js
...
4
votes
1
answer
424
views
Abstract base class for binary serialization
Ensuring that some logic is always being run before the user's overriding methods.
I'm writing a library and I have some abstract classes that can be binary serialized (and users can subclass them and ...
2
votes
1
answer
527
views
Statically allocated buffer using templates
I want to have some classes that would contain arrays of different sizes. I want this to be statically allocated because it is intended for an embedded system. The only good solution I can think of is ...
2
votes
1
answer
85
views
Reversing a type converter with minimal redundancies
The objective is to implement the reversed version of StringToDoubleConverter but without writing too many redundancies. I love DRY (Don't Repeat Yourself) design ...
0
votes
1
answer
501
views
Class that counts its instances
I'd love some feedback on the C++ base class shown below. It's basically a toy problem for a fake video game where the monsters that you have to avoid will all be sub-classed from the class shown ...
2
votes
0
answers
127
views
A Python base class for a family of Postgres server manager classes
I'm working on a repo the purpose of which is to create and manage a local PostGIS server. (PostGIS is a bit niche, but it boils down to a few extra spatial data types and built-in SQL function. With ...