operator-overloading Questions
2
Solved
In this example code, why isn't
using IParameterBase<TYPE>::operator=;
working, and the base class assignment operator working?
I recently changed to this templated version, previously I had ...
Lucifer asked 3/10 at 11:39
2
Solved
According to the Swift Programming Guide, operator overloading is allowed and actually quite versatile. However, I have been unable to get it working in the playground.
For example, the Equatable ...
Ourselves asked 10/6, 2014 at 18:14
3
Solved
I have a template class Array:
template <class T=int, int SIZE=10>
class Array {
T TheArray[SIZE];
public:
void Initialize() {
for (int idx=0; idx < SIZE; idx++) {
TheArray[idx] = T()...
Protrusile asked 4/1, 2016 at 14:22
9
Solved
I need to define an Interface which has to enforce certain operator overloading to the types which implements it. There doesn't seem an obvious way to do it since operator overloading has to be don...
Elysha asked 28/9, 2010 at 9:16
5
Solved
I have a struct that's defined like this:
struct Vec3 {
float x, y, z;
};
When I attempted to use std::unique on a std::vector<Vec3>, I was met with this error:
Description Resource ...
Fabyola asked 25/3, 2012 at 1:11
4
Solved
Following the advice given in this answer, I have overloaded the + operator in my simple Point class as follows (the += overload works fine).
Point operator+ (Point p1, const Point& p2)
{
ret...
Cavill asked 25/11, 2012 at 18:57
7
Solved
How can I overload the |= operator on a strongly typed (scoped) enum (in C++11, GCC)?
I want to test, set and clear bits on strongly typed enums. Why strongly typed? Because my books say it is goo...
Often asked 8/4, 2013 at 21:34
3
Solved
This is what I tried, but I see that overloading only increments the variable if I assign it to another variable. I.e, The value of the variable on which I do the increment does not increase. So, i...
Recapitulation asked 23/7, 2017 at 6:16
10
Solved
I came across this recently, up until now I have been happily overriding the equality operator (==) and/or Equals method in order to see if two references types actually contained the same data (i....
Leroy asked 19/9, 2008 at 18:7
4
Solved
In my small project I'm using System.Reflection classes to produce executable code. I need to call the + operator of a custom type. Does anybody know how can I call customized operator of custom cl...
Colangelo asked 20/6, 2012 at 5:22
5
Solved
I've started learning C++, so I don't know in my lack of knowledge/experience why something so seemingly simple to a rookie as what I'm about to describe isn't already in the STL. To add a vector t...
Chorale asked 16/6, 2011 at 1:38
6
Is it not supposed for a friend function to be explicitly defined outside of a class ?
If so why can i declare a friend function inside a class definition just like any member function ?
What is th...
Teliospore asked 7/7, 2013 at 13:25
5
I'd like to ensure my RAII class is always allocated on the stack.
How do I prevent a class from being allocated via the 'new' operator?
Mckenna asked 24/9, 2008 at 1:18
9
Solved
That's basically the question, is there a "right" way to implement operator<< ?
Reading this I can see that something like:
friend bool operator<<(obj const& lhs, obj const& rh...
Conditioned asked 25/10, 2008 at 18:19
4
Solved
Do polymorphism and operator overloading mix together?
You can't do polymorphism without pointers, as it is explained in this answer and also you can't do operator overloading with pointers as expl...
Gothicize asked 29/6, 2012 at 8:43
7
Solved
Precondition: Consider such a class or struct T, that for two objects a and b of type T
memcmp(&a, &b, sizeof(T)) == 0
yields the same result as
a.member1 == b.member1 && a.memb...
Ascender asked 4/3, 2015 at 15:31
10
Note: This question and the original answers are from 2010 and partially outdated. Most of it is still good and helpful, but the original text no longer covers everything there is to know about C++...
Overby asked 12/12, 2010 at 12:44
10
Note: This question and the original answers are from 2010 and partially outdated. Most of it is still good and helpful, but the original text no longer covers everything there is to know about C++...
Kati asked 12/12, 2010 at 12:44
11
Solved
I can't seem to find the way to overload the [] operator in javascript. Anyone out there know?
I was thinking on the lines of ...
MyClass.operator.lookup(index)
{
return myArray[index];
}
or am I...
Hootenanny asked 10/11, 2009 at 21:31
4
Solved
What is the specific code, in order, being executed when I ask for something like
>>> 1 <= 3 >= 2
True
If both have equal precedence and it's just the order of their evaluation, w...
Creepie asked 30/9, 2012 at 2:43
1
Solved
Consider the following code (godbolt link):
#include <cstdio>
int main() {
auto foo = operator new;
void* mem = foo(1);
printf("%p", mem);
}
This code compiles on GCC, Clang, a...
Runaway asked 28/7, 2023 at 12:44
1
The code below allows you to see size of variable being deleted:
#include <iostream>
#include <stdlib.h>
using namespace std;
struct P {
static void operator delete(void* ptr, std::si...
Charlenacharlene asked 13/7, 2023 at 0:48
10
Solved
I've been working with JavaScript for a few days now and have got to a point where I want to overload operators for my defined objects.
After a stint on google searching for this it seems you can'...
Sothena asked 27/10, 2013 at 16:51
11
Solved
Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it.
Dre asked 6/11, 2009 at 10:23
2
Solved
I have a pointer to some volatile memory that I am trying to dereference and copy to a unqualified copy of that structure (and vise-versa). The format of the memory is specified by a third party st...
Extranuclear asked 6/6, 2023 at 0:10
1 Next >
© 2022 - 2024 — McMap. All rights reserved.