Skip to main content

All Questions

Tagged with
-1 votes
1 answer
233 views

How to overload the subscript operator in C++? [duplicate]

I'm working on a C++ project and I need to implement subscript operator overloading for a class. Specifically, I want to be able to use the square bracket notation ([]) on an object of my class to ...
Avacado78329's user avatar
1 vote
1 answer
110 views

How to overload the add operator to return the length of two string when they are added?

I am trying to create a class diffStr that behaves like str except, when a user tries to add or multiply two strings, the output is the length of each string added or multiplied (respectively). My ...
Harsh Darji's user avatar
-3 votes
2 answers
353 views

C++ no match for ‘operator=’

I've created a class to simulate the behavior of vector of int, because every time I read or write some value, also a read and write counter should be incremented to keep track of its usage. I can’t ...
Opaco's user avatar
  • 3
4 votes
1 answer
189 views

Overload assignment operator and rule of zero [duplicate]

I have written a template class A<T> and I am making use of the rule of zero (I let the compiler generate the destructor, copy/move constructors and assignment operator overloadings). However, I ...
Urwald's user avatar
  • 461
1 vote
0 answers
85 views

Overloading operator&& it's return type

I have the following general class: class Example { public: Example(std::string _a): a(_a) {} std::string a; } I want to overload the operator&& and || to be able to do something like ...
Ovidiu Firescu's user avatar
0 votes
0 answers
51 views

How to overload operators in c++ [duplicate]

#include <iostream> #include <string> class TOperator { private: string name; public: TOperator(string name) { this->name = name; } TOperator(); void setName(string name) { ...
hurricanek218's user avatar
-1 votes
1 answer
214 views

operator overloading abstract class

There is an Student abstract class, and two derived class Grad and Undergrad; and I want to overload operator in several ways. student.h class Student { protected: string Name; int Stu_num;...
gun bos's user avatar
  • 51
0 votes
2 answers
683 views

how to overload + operator to add two queues?

I want to add two queues I have defined, what's wrong with my overloading method ? I have tried the exact syntax of operator overloading but it did not work !! These queues are dynamic arrays that we ...
Sasan Ace's user avatar
0 votes
0 answers
34 views

C++ Can someone explain me this << and >> operation overloaded for showing a class content?

I hope this question don't get banned to me. It's a knoob question, but i don't know how the things are working here. I have the following istream and ostream overloaded << and >> ...
Lucas 's user avatar
  • 351
2 votes
1 answer
195 views

My pre increment is working fine but not the post increment

I have implemented the following class and tried to overload the pre and post-increment operator along with the extraction '>>' operator. The programs runs fine till 'cout << ++num1;' but ...
Muhammad Arslan Waqar's user avatar
-2 votes
1 answer
56 views

extended assignment statements in Python [closed]

How can I add extended operators(below). Generally speaking how can I implement such an operator (for example only one). X+=Y X-=Y X*=Y X\=Y X%=Y X&=Y X**=Y X=Y X—=Y X//=Y X<<=Y X<&...
JosephAndrew2's user avatar
1 vote
1 answer
59 views

How can I overload these operators to make this program work?

To keep things simple, this is my class assignment: Add the following functions to the Cspinner class. Overload the equal sign to compare two spinners. The following instruction should be valid if w1,...
Gerald Marcano's user avatar
0 votes
0 answers
24 views

C++ Overloading "<<" operator twice [duplicate]

I would like to overwrite the "<<" operator three times. Bottle 2 should give bottle 1 some water. For example: Bottle bottle1(200); Bottle bottle2(200); bottle1 << 200 << ...
Rkhf's user avatar
  • 1
0 votes
1 answer
122 views

Overloading an operator to return areas

I'm trying to overload 2 operators. I want to overload the '*' operator to return the area of two intersected rectangles. Then, I'm trying to overload the '+' operator to find the sum of the areas of ...
john's user avatar
  • 29
1 vote
2 answers
43 views

I have overloaded << and = operators. Why when I assign an object to another and try to print it I get junk printed out?

I have a program with a class Length. This class has an attribute named size of type int and a dynamic array *numb of type char. I have overloaded operators << and = so that I can print object ...
C96's user avatar
  • 519

15 30 50 per page
1
2 3 4 5
9