Operator overloading is a feature of a programming language that allows custom implementations for operators depending on the types of the operands involved. Some languages allow new operators to be defined while others only allow redefinition of existing ones.

learn more… | top users | synonyms

0
votes
0answers
15 views

C++ << operator overloading and templates with Arduino

I'm working on an arduino project where I have been using the following template for printing various data types with the << operator template<class T> inline Print &operator ...
2
votes
2answers
10 views

Enable a Rational class to handle math operators

I have this Rational class that has a method for each operation (add,mult etc) function Rational(nominator, denominator){ this.nominator = nominator; this.denominator = denominator || 1; ...
1
vote
2answers
18 views

LNK2019 with pure virtual assignment(=) operator in multilevel class hierarchy?

Ok, maybe i'm too fatigued to think about the solution to this problem, I looked a lot about a similar problem on the internet but didn't find one. So here's my terrible code: class X { public: ...
0
votes
2answers
60 views

Strange program crash

I'm trying to implement a String class for an excercise. Here is my all code: (you don't need to read it all) : #include <iostream> using namespace std; // ******************************* ...
1
vote
2answers
42 views

`operator<<` on comma separated values in C++

The following syntax is working in OpenCV Mat R = (Mat_<double>(4, 4) << 1, 0, 0, 0, 0, cos(alpha), -sin(alpha), 0, 0, sin(alpha), cos(alpha), ...
0
votes
2answers
73 views

C++ copy constructor, overload assigment operator , methos get()

I had an exercise in my university in c++. So the course they asked me to make a copy constructor and an overload assigment operator = . So i did and it worked fine. They said me that i am wrong in ...
2
votes
3answers
53 views

C++ operator overloading and parameterized constructors

Why does the below C++ program output "ABaBbAc"? #include "stdafx.h" #include <iostream> using namespace std; class A { public: int i; A(int j=0):i(j) { cout<<"A"; ...
0
votes
1answer
47 views

overloading operator< for pointers to class object

I'm trying to figure out how to implement an operator< overload for an Item Pointer class that points to an Item class object. It is part of a program that stores pointers to Items in an STL set. ...
0
votes
2answers
61 views

Overloading << operator - multiple parameters

Many of you may know the following in C++: cout << 1 << 2 << 3 << 4; // would produce 1234 I'm attempting to recreate the same thing - but instead encapsulate it into a ...
0
votes
1answer
73 views

c++ overload the [] operator for write/set

I have done numerous searches and found a ton of examples and tutorials but still cannot figure out how to get the value when writing to the [] operator... I feel like i'm going insane. I must be ...
3
votes
1answer
72 views

Operator overload requires parenthesis

I have overloaded both & and *. If I do this: hgh=(xxx&yy)*vprod1; It works as expected. If I do this: hgh=xxx&yy*vprod1; I get a compiler error Invalid operands to binary ...
-2
votes
2answers
49 views

C++ operator overloading constructor

Can some one explain how below program becomes infinte loop of "AabAabAab.." #include "stdafx.h" #include <iostream> using namespace std; class Base { public: Base(int j=1):i(j) ...
14
votes
9answers
542 views

C++ operator overloading

Why does the below C++ program output "ACCA"? Why is operator int() called twice? #include "stdafx.h" #include <iostream> using namespace std; class Base { public: Base(int ...
-2
votes
0answers
84 views

Concatenate two Linked Lists with operators += and + [closed]

I wrote my class to implement a linked list (it's an exercise to practise the concepts studied); at first, I implemented it to store a char, and now I'm trying to convert it in a template. My class is ...
0
votes
2answers
54 views

Relational operators on a class template

This will not work template<typename T> struct foo { T t; }; bool operator==(const foo &lhs, const foo &rhs) { //error, requires template arg return lhs.t == rhs.t; } Is this the ...

1 2 3 4 5 158
15 30 50 per page