Skip to main content

Questions tagged [overloading]

The terms overloading and overloaded may refer to: - Constructor and method overloading, a type of polymorphism where different functions with the same name are invoked based on the data types and number of the parameters passed - Operator overloading, a form of functional or method overloading where the action being overloaded is an operator, such as + or -

Filter by
Sorted by
Tagged with
-3 votes
1 answer
81 views

Initializing an object using a staticmethod

I've an object that looks like this, and users have been populating the attributes post-initialization, e.g. ...
alvas's user avatar
  • 699
5 votes
1 answer
248 views

uint24_t implementation ported to Windows

I coded stuff for an embedded device where int is 24bits. I wanted to port uint24_t and ...
Vortex 2728182818's user avatar
5 votes
1 answer
214 views

Is there a more idiomatic way than this to use template-generic C++23 multidimensional array subscripts?

C++23 is going to add multidimensional array subscript operators to the language, yippee! Alas, I have not yet come across a way to adapt them to types where the number of dimensions is templated, so ...
saxbophone's user avatar
1 vote
2 answers
151 views

A simple String class and its special member functions

I am learning the behavior of C++'s special member function, using a naive String class as example. (The code is modified from this tutorial) Here is the ...
Lion Lai's user avatar
  • 297
2 votes
1 answer
94 views

API design for Implementing NaN/Unknown values for custom numeric type

I'm gradually writing an arbitrary-precision arithmetic library for C++. I've decided it could be useful to have the default constructor produce an object of indeterminate value, rather than relying ...
saxbophone's user avatar
4 votes
1 answer
294 views

Comparison operator for ranges C++

If you want to lexicographically compare two vectors in C++, you can simply write vec1 <=> vec2. But instead, if you want to compare them reversed, it is not ...
Sourav Kannantha B's user avatar
2 votes
2 answers
333 views

Template Complex class

I have created a class Complex which represents a complex number of any arbitrary arithmetic type. Overloads are given for the 4 common functions, addition, ...
finlay morrison's user avatar
0 votes
1 answer
67 views

Almost identical methods to print an array, differing only by argument type [closed]

It's very basic. I'm learning C# and I want a method to print an array in a readable format. My array could be integers, doubles, or strings. I have implemented method overloading. From the fact that ...
tmo's user avatar
  • 33
12 votes
3 answers
2k views

Matrix implementation

I am trying to implement an optimal and fast running matrix in C++. I need some review of the code and ideas on how to improve the code quality if it shall be. ...
Hrant Nurijanyan's user avatar
1 vote
1 answer
275 views

Syntax to Overload the Post-Increment Operator ++ as a Nonmember Function

I know this may be a silly question, but... is it really necessary to add the parameter name (int <parameter_name>), instead of just (int) in a definition of an operator function to overload &...
jr.çhåvez__07's user avatar
2 votes
1 answer
205 views

Operator overloading in Image class implementation in C++

This is a follow-up question for Dictionary based non-local mean implementation in C++. There are some issues about operators (operator+ and ...
JimmyHu's user avatar
  • 5,510
4 votes
3 answers
942 views

C++ money class for basic banking application

I wanted to get my code reviewed as I have tried to implement a basic Money class to represent money values in c++. Can anyone tell me if I am implementing my basic arithmetic operator overloads ...
paigelarry342's user avatar
2 votes
2 answers
544 views

Fractions in C++

I started learning classes and operator overloading in C++. To test my skills I decided to make a Fraction class with all necessary operations. I would appreciate improvements and suggesstions on my ...
Random_Pythoneer59's user avatar
1 vote
1 answer
324 views

Unit Tests for the operators of image template class with Boost.Test framework in C++

This is a follow-up question for Tests for the operators of image template class in C++. As G. Sliepen's answer mentioned, I am attempting to use Boost.Test and several test cases are created with <...
JimmyHu's user avatar
  • 5,510
2 votes
1 answer
110 views

Tests for the operators of image template class in C++

This is a follow-up question for Two dimensional gaussian image generator in C++. Thanks for Cris Luengo's answer and JDługosz's answer. I am attempting to update the implementation of ...
JimmyHu's user avatar
  • 5,510
2 votes
2 answers
4k views

C++ overloading += operator in custom string class better implementation

I am trying to learn C++, so I started coding a custom string class (using only c-style strings) to get familiar with concepts like operator overloading etc. in the case we have a pointer attribute. I ...
Kostas Letros's user avatar
4 votes
1 answer
4k views

Piping operator in c++

I wrote a simple piping operator in c++. I just wanted to make sure that my code was robust, modern c++ code, and made correct use of perfect forwarding. Here's the code: ...
SomeProgrammer's user avatar
2 votes
1 answer
60 views

Colour-model classes using CRTP

I want to implement color space logic. So I started with creating some structs: ...
Hrant Nurijanyan's user avatar
3 votes
2 answers
1k views

C: struct timespec library

I'm trying to write a minor lib that would enable me to measure average time measured when using struct timespec. Since C doesn't allow operator overloading, I'm ...
user233832's user avatar
3 votes
2 answers
72 views

C++ PixelComponent struct

Hey I wrote a struct in C++ trying to represent a Pixel Component of a color Here it is ...
Hrant Nurijanyan's user avatar
3 votes
1 answer
381 views

Over overloaded method

I am using SignalR to send notifications to clients. I use IClientProxy which is a proxy for invoking hub methods. It has 10 overload methods for ...
Can PERK's user avatar
  • 133
3 votes
1 answer
72 views

Different versions of the Operate method

I have code that basically is the same, but depending on the number of arguments you provide (up to 5), it will operate with them in a very repetitive way. I have the feeling that this can be ...
SuperJMN's user avatar
  • 233
3 votes
1 answer
218 views

C++ algorithm to implement multiple operators in one

I have a class called IntMatrix which has 2 fields: ...
user225756's user avatar
1 vote
1 answer
48 views

Varying Parameter Names in Method Overloads

Probably a dumb question but just can't seem to make a decision here. I'm building a C# class library that I intend for other developers to use. Let's say one of these classes contains a method that ...
isuckatprogramming's user avatar
5 votes
1 answer
101 views

C++ simple dictionary match and insert, unique_ptr, operator<

I'm learning C++ and did some reading here and elsewhere on trie structures. I've written a simple class that performs insert and match using a sorted vector as the underlying container. I used ...
gccross's user avatar
  • 53
3 votes
2 answers
167 views

Overloading == for better readability

I was working on a project recently that had a good amount of business logic associated with status codes. To better understand the flow of logic in the domain layer, I created an enum ...
FDaniels's user avatar
2 votes
1 answer
185 views

type erased pointer to member function callable and SFINAE [closed]

I'm implementing a std::function like class that uses type erasure. So far it can be used with function objects (functions/function pointers, functors, lamdas) and pointer to member function. But to ...
Luca's user avatar
  • 123
0 votes
2 answers
756 views

Array indexing with copy constructor, assignment operator and index operator overload

The code below is a custom array class that handles indexing, copying, printing, etc. explicitly. Is there a better approach for specification (declaration and definition) of the assignment operator (...
Darnoc Eloc's user avatar
5 votes
2 answers
91 views

Range check operator

I'd like to improve this operator code if I can. I don't know enough Raku to write idiomatically (or any other way for that matter), but suggestions along those lines would be good also. ...
hsmyers's user avatar
  • 153
5 votes
1 answer
204 views

Overloading python class constructor

I am trying to create a very basic class: Line as follows: ...
IamNotaMathematician's user avatar
3 votes
2 answers
878 views

Operator overloading in C++ to manage playlists of music

I've built this little C++ program just to take some rust off my coding skills since it's been ages since the last time I coded something. The purpose is to organize my music, so I've built the ...
agneau's user avatar
  • 341
4 votes
2 answers
263 views

Two classes to avoid confusion when handling degrees and radians

Experimenting with operator overloading for the first time. Based on my reading, it appears to be a bit of a minefield. Have I fallen into any traps? ...
pingu's user avatar
  • 173
2 votes
0 answers
87 views

Python adding partialmethods to a class at compile time

I am writing a class for delayed operations on variables which are resolved at a later time. I am using pythons operator overloading but my class definition seems very boilerplatey. Is there a more ...
Justin Fay's user avatar
4 votes
1 answer
96 views

Program containing several bitset based classes including chars, strings, ints and a base bitset class

This is by far the biggest project i've ever made. The main goal was just to make a bitset class but it expanded into making several classes based off of that main bitset class. Some things I would ...
Cow Nation's user avatar
7 votes
1 answer
2k views

Overloading istream>> to read comma-separated input

I have the following very simple class: ...
Daniel Duque's user avatar
5 votes
2 answers
1k views

C++ Pixel/Array manipulation libs

I was tired to always perform pixel manipulation one by one, so I started to create my own templated header to perform computation over pixel (RGB, or RGBA), but I also make it for ND for some cases. ...
Vuwox's user avatar
  • 153
2 votes
2 answers
453 views

Polymorphic implementation for == with CRTP

I'm trying to implement equality for all types that share same base. Consider std::vector<unique_ptr<Shape>> and that we want to check if a certain ...
Amir Kirsh's user avatar
-2 votes
3 answers
49 views

Refactorizing overloads with the same scope but different calls [closed]

Well I have 3 methods that are overloads, but in it's scope has the same scope except one method call. ...
z3nth10n's user avatar
  • 247
3 votes
2 answers
4k views

Class to store and manipulate Cartesian coordinates and vectors

I have made a C++ class to manipulate 3D vectors in Cartesian coordinates. However, the performance of my class is much slower (about 2.5x) than simply using something like ...
josh_eime's user avatar
3 votes
1 answer
770 views

C++ - Astar search algorithm using user defined class

The objective of the post is to improve design and improve command on C++. Given a map, start point and end point, the shortest path to end point from the start point has to be found out using Astar (...
skr's user avatar
  • 539
3 votes
1 answer
666 views

Function overloading in Python

Motivation As an exercise, I wanted to try implementing function overloading in Python 3, i.e. to implement a way of defining multiple functions with the same name and then calling the appropriate ...
igal's user avatar
  • 381
1 vote
2 answers
70 views

Generic function with same logic but different input structure

I have a data structure that looks like this: interface Node { originalWeight: number; currentWeight: number; } where both properties are floats between <...
bugs's user avatar
  • 113
5 votes
3 answers
252 views

Basic binary number container

Summary: a templated class, whose main purpose is to store a binary representation of a decimal number. I choose array of booleans as a storage, since bitset was forbidden. One of the requirements was ...
Inter Veridium's user avatar
1 vote
1 answer
87 views

Overloading Java function (insert into binary tree)

I have a binary tree below and it seems to make sense to overload the insert() method. If insert() is called without a ...
M3RS's user avatar
  • 373
1 vote
3 answers
4k views

Cartesian/polar coordinates program

Can I get my program checked for efficiency? As in, see if there are better ways of writing my code, for example, making more efficient use of memory and/or security options like where to use ...
Josh Little's user avatar
5 votes
1 answer
122 views

Class Iteam: Answer to one of the unsolved Stack Overflow Qes

I would like to improve my skill on C++ concepts and I came across the following question in StackOverflow, which has been directly asked by a StackOverflow-user without any preliminary attempts.(...
user avatar
1 vote
1 answer
679 views

Get column of a matrix python with index operator

How can I refactor this code to generalize the argument parsing? I feel like this code can be better but I can't find a way. The usage syntax of the index operator is similar to the NumPy indexing ...
honeyspoon's user avatar
5 votes
2 answers
562 views

Overriding operator delete/new to check correct pairs of (non-)array variants

A legacy project I am maintaining in my freetime uses overrides of operator delete / operator new. These overrides over-allocate ...
Zsar's user avatar
  • 151
2 votes
1 answer
249 views

Operator overloading for Boost interval (vectors)

I am a complete newbie to C++ and programming in general. I need to write something for scientific purposes and as such, performance is crucial. I introduced two types, matrices and vectors with ...
bernhard_e's user avatar
1 vote
2 answers
116 views

C++ limiting a method for an rvalue caller, an expression evaluator example

There are many ways to implement a math expressions evaluator (I focus here just on the evaluator part, without any parsing). I want to explore a certain implementation to support the following main: ...
Amir Kirsh's user avatar