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
0 votes
1 answer
63 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 ...
user avatar
  • 33
11 votes
3 answers
825 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. ...
user avatar
1 vote
1 answer
99 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 &...
user avatar
2 votes
1 answer
113 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 ...
user avatar
  • 3,556
4 votes
3 answers
594 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 ...
user avatar
2 votes
2 answers
133 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 ...
user avatar
1 vote
1 answer
78 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 <...
user avatar
  • 3,556
2 votes
1 answer
66 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 ...
user avatar
  • 3,556
2 votes
2 answers
731 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 ...
user avatar
3 votes
1 answer
146 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: ...
user avatar
2 votes
1 answer
36 views

Colour-model classes using CRTP

I want to implement color space logic. So I started with creating some structs: ...
user avatar
1 vote
0 answers
73 views

Boost speed optimizations,C++ operator overloading

I am writing a part of the program where speed matters the most. In that part I am creating color spaces like RGB and other. In-fact I wrote these 2 structs. ...
user avatar
3 votes
2 answers
523 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 ...
user avatar
3 votes
2 answers
60 views

C++ PixelComponent struct

Hey I wrote a struct in C++ trying to represent a Pixel Component of a color Here it is ...
user avatar
3 votes
1 answer
192 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 ...
user avatar
  • 133
3 votes
1 answer
66 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 ...
user avatar
  • 213
3 votes
1 answer
115 views

C++ algorithm to implement multiple operators in one

I have a class called IntMatrix which has 2 fields: ...
user avatar
1 vote
1 answer
37 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 ...
user avatar
5 votes
1 answer
69 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 ...
user avatar
  • 53
3 votes
2 answers
160 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 ...
user avatar
2 votes
1 answer
64 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 ...
user avatar
  • 123
0 votes
2 answers
467 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 (...
user avatar
5 votes
2 answers
83 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. ...
user avatar
  • 153
5 votes
1 answer
161 views

Overloading python class constructor

I am trying to create a very basic class: Line as follows: ...
user avatar
3 votes
2 answers
548 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 ...
user avatar
  • 351
4 votes
2 answers
122 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? ...
user avatar
  • 173
1 vote
0 answers
33 views

Overloading both for (non) constant access [closed]

I'd offer a couple of iterator accesses to the class member, both constant and non-constant. I came to the following solution, but it seems to me far more verbose than needed. I'd like somehow to ...
user avatar
2 votes
0 answers
75 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 ...
user avatar
4 votes
1 answer
58 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 ...
user avatar
7 votes
1 answer
2k views

Overloading istream>> to read comma-separated input

I have the following very simple class: ...
user avatar
4 votes
2 answers
655 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. ...
user avatar
  • 143
2 votes
2 answers
288 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 ...
user avatar
-2 votes
3 answers
44 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. ...
user avatar
  • 227
3 votes
2 answers
3k 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 ...
user avatar
3 votes
1 answer
567 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 (...
user avatar
  • 539
3 votes
1 answer
474 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 ...
user avatar
  • 371
1 vote
2 answers
62 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 <...
user avatar
  • 113
5 votes
3 answers
224 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 ...
user avatar
1 vote
1 answer
51 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 ...
user avatar
  • 299
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 ...
user avatar
5 votes
1 answer
113 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
439 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 ...
user avatar
5 votes
2 answers
357 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 ...
user avatar
  • 151
2 votes
1 answer
192 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 ...
user avatar
1 vote
2 answers
114 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: ...
user avatar
1 vote
0 answers
76 views

Practice global operator new for my Fruit class and Apple derived class?

I want to practise global operator new/delete and new[]/delete[], how can I improve it? Here are one Fruit(Base) Class, and one Apple(Derived) Class. ...
user avatar
  • 475
4 votes
1 answer
292 views

Overloading __getitem__() for two key types in Python

I've got a collection of users with two types of IDs (a_id, b_id) where one is a positive integer and the other is a six-letter string. For my collection class, I'd like to be able to look up users ...
user avatar
  • 711
4 votes
1 answer
491 views

Operator Overloading Tricks in C++

This method is taken from Syntactic Aspartame. This is my attempt at a generic version. The goal is to create an operator X <NAME> Y where name is anything, ...
user avatar
5 votes
1 answer
126 views

Author class, with constructor validations and rich comparisons

I wrote the following Author class in Python for a project I'm working on. I wanted to make sure that the rich comparisons and the methods I used to validate the constructor parameters were done ...
user avatar
3 votes
2 answers
230 views

C++ String Non-Member Operator Overloading

This is a practice for operator overloading, I am well aware that some of these don't make sense. I am seeking review only on the code/practices, not the purpose. ...
user avatar