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 ...
2
votes
2answers
62 views
Find combination of sets which sum up to a specified result
Example input :
A) 1, 2
B) 2, 8
C) 7, 8
Required Result : 8, 10
The output from the program with this input should be A + C.
Few notes :
We can only combine 2 sets.
There must ...
2
votes
1answer
70 views
C++ operator overloading for matrix operations - follow-up
This is improved code after I some issue in pointed by @Edward in the last question: C++ operator overloading for matrix operations
This work assignment in operator overloading .I need to use ...
1
vote
2answers
128 views
C++ operator overloading for matrix operations
Please check the code to see if there anything I can improve .
Everyting is working as expected.
matrix.h
...
4
votes
2answers
428 views
Python-style string multiplication
When people migrate from Python to C++, they're often bothered by the fact that C++ strings don't support multiplication like Python's strings do.
std::string does ...
1
vote
1answer
57 views
An iterator which behaves like an array with uniform values
I'm implementing an iterator which takes a single value and which you can advance for n times with a dereferencing yielding the single value - but before or after that range of n 'positions' you can't ...
3
votes
2answers
228 views
C++ code to find distance between line and point
So I made this simple program that allows users to construct points and lines and then return the smallest distance between a given point and a line. In doing so I have used some OOP concepts and ...
2
votes
3answers
357 views
Overloaded handlers for various configurations retrieved from a database
I have a switch statement that references different configurations based on data pulled from a database. Each iteration of configuration has variations in what needs to be enabled/modified.
I've set ...
-1
votes
1answer
109 views
Using templates and function overloads to set DOM attributes [closed]
I'm making a library to build and manage a website. I want to control what gets to be inserted. For example I don't want to be able to insert ...
2
votes
3answers
119 views
Functor to compare two floats with tolerance
What do you think about this implementation of 2 floats comparison functor considering how tolerance is introduced?
...
3
votes
1answer
122 views
Recursive flattening of Swift sequences - an overly complicated approach
I recently read and answered Martin R's Recursive flattening of Swift sequences and continued to play around with the code until I arrived at something that was both pretty cool and possibly an ...
3
votes
1answer
48 views
Overloaded applyRestrictionsToCriteria(…) methods
We want to refactor two methods that are exactly the same, except for one difference: one takes an org.hibernate.Criteria and the other ...
5
votes
2answers
348 views
Single Linked-List Implementation in C++
I haven't done much C++ coding the last few years, so I've been reviewing in preparation for upcoming interviews. I wrote a minimally functional singly linked-list. I'm using my implementation for ...
1
vote
1answer
87 views
Operator Oveloading: “+” and “==” for two classes
I have one class Number (base class) and two child class Fraction and ...
0
votes
1answer
772 views
Add two fractions or two integers using template class and overloading
Question:
Need to create three classes.
Number
Fraction
Integer
Requirements
The first class should support “display”, “==”, and “+”.
"Display" : This operation displays the Number itself in its ...
0
votes
1answer
264 views
Polynomial class C++11
Initial stage of implementation of the polynomial class. Essentially I need to implement the basic mathematical operations. Right now I have implemented just addition. Was wondering if this is a good ...
5
votes
3answers
2k views
Comparing Equals() method from MSDN
I've implemented the Equals() support for my class as follows:
...
3
votes
1answer
170 views
Overloading operator ->* for smart pointers
I am implementing a smart pointer class template and I want to overload operator ->* (even if it’s rarely done). I came across Scott Meyer’s article Implementing ...
3
votes
1answer
43 views
Addition operators for length units
I'm writing some code that helps me deal with units better, by having a user defined type for things like Metres, Centimetres ...
6
votes
3answers
2k views
Money class with overloaded operators
I have program that uses a Money class which has several constructors for different methods of input and overloaded operators to add, subtract, and compare values.
...
1
vote
1answer
34 views
Getting a table from an Excel worksheet
I need to get a table from an Excel worksheet. Sometimes I know the worksheet that contains the table, other times I might know it's going to be in one of a handful of worksheets, and still other ...
-3
votes
2answers
306 views
Is the Copy-Swap Idiom implemented here correctly? [closed]
Is the Copy-Swap Idiom implemented here correctly?
...
6
votes
2answers
2k views
3
votes
2answers
60 views
5
votes
1answer
129 views
Overriding GetHashCode and Equals
I'm creating a class to wrap a list of Mask and I'd like to know if I'm overriding the GetHashCode() and ...
5
votes
3answers
4k views
Basic complex number class
As part of my C++ training, I wanted to create a basic complex number class for basic complex number calculations.
The class should have the following:
constructor (non explicit, for implicit ...
6
votes
1answer
2k views
Calculator - C++ operator-overloading
I am new to object-oriented concepts. The following is my attempt at creating a basic calculator using class and operator overloading concepts. Please review it for improvements. Also, how do I make ...
5
votes
2answers
131 views
Overloading email sender utility class methods take single or array arguments
I'm writing a simple utility class for sending an email. I'm not sure what's the proper way to present this to a consumer. Should I force them to use an array in ...
3
votes
1answer
314 views
Implementing binary output to a file in C++11
I would like to have a class which supports outputting bits into a file. This is what I came up with but I fear there are many poor decisions. Should I inherit from a ...
3
votes
2answers
604 views
Emulating __uint128_t
I developed a lot of code locally with __uint128_t only to find out that it is not available on the target platform.
I am now trying to write my own struct that ...
7
votes
1answer
233 views
Multiple dispatch decorator classes in Python
This is based on my first review and the suggested points in "Multiple dispatch decorator in Python":
...
27
votes
4answers
1k views
Standardly deviated Fibonacci
I'm new to C++ (about 4 weeks with no prior programming experience in other languages) and am writing a program that's supposed to do the following:
Define an array of 100 sequential numbers of type <...
5
votes
2answers
579 views
Providing const- and non-const overloads of a strstr() implementation
In a question about reimplementing strstr(), I posted an answer. I pointed out a need for const- and non-const versions of the function, and provided ...
5
votes
2answers
816 views
Overloading operators in PhoneCall class
I am trying to understand the concepts of friend functions, overloaded operators, and inheritance in C++. I am very confused on the specifics used for coding, since ...
2
votes
2answers
426 views
Grails overloaded controller workaround
I had an overloaded method, but Grails doesn't allow overloaded methods in controller actions. The overloaded method looked like this:
...
5
votes
1answer
6k views
Review of 2d Vector class
I'll keep this short. I've never actually done professional C++. I don't really know any of the 'best practices'. I'd like to get some review on a simple class that I've made.
My Vector2d.h file:
<...
8
votes
2answers
4k views
Generic Calculator and Generic Number
.NET does not support generic numbers. It is not possible to enforce a generic method with generic argument T that T is a number. The following code will simply not compile:
...
42
votes
2answers
2k views
Named operators in C++
A post by Yakk alerted me to the idea of named operators in C++. This look splendid (albeit very unorthodox). For instance, the following code can be made to compile trivially:
...
4
votes
1answer
468 views
Implementing C++ boolean function objects with logical operator combinations
I want to make a C++ object hierarchy of "classifiers", which can be composed together via logical operators into a single classifier that implements the whole logical combination.
This is actually ...
8
votes
1answer
306 views
Avoid duplicated += -= operator code
In C++ (and C++11), classes defining a + and += operators often define a - and ...
1
vote
1answer
1k views
Extending string mapping
Basically I'm trying to generalise and extend the notion of mapping one string into another.
There are two methods I often find myself using for this: Functions, and Dictionairies.
So here are my 3 ...
4
votes
1answer
2k views
Custom operator new and operator delete
In our embedded application, we have to replace ::operator new and ::operator delete to call a special ...