39 Topics

Member Avatar for
Member Avatar for embooglement

I'm trying to write a to string function that would use std::stringstream to convert the the instance data into a string, but haven't been able to get operator overloading to work with it. As soon as I define a new << operator, I get a bunch of ambiguity errors saying …

Member Avatar for embooglement
0
2K
Member Avatar for sbrohee

Hi everyone, I am quite new to C++ (coming from perl). As an exercise, I am currently trying to create a class to play with graphs. I have a class Node in which I overload the == operator (to test the equality between two nodes). At the moment, I consider …

Member Avatar for sbrohee
0
265
Member Avatar for Alex_

I'm trying to make the container to work with one of my classes. But i don't understand what should the overloaded operator contain. Maybe this is because i don't know the container too well... Please give me some insights. This is my class [code=C++] class Complex{ private: int re; int …

Member Avatar for mitrmkar
0
158
Member Avatar for RayRay1

I am writing a rational number class and need to know if this is the correct way to do it. Can someone please let me know if I'm on track or not? Thanks. [CODE]class RationalNumber { public: RationalNumber( int = 0, int = 1); // constructor RationalNumber operator+( const RationalNumber& …

Member Avatar for RayRay1
0
831
Member Avatar for ryan8806

hi guys, i'm having a bit of a prolem with C++, i've been programming c# for quite a while now, so i am not a novice lol. problem -- i've created the following ofstream in my main method: [CODE]ofstream out1("array1.txt");[/CODE] however later on in the code i call [CODE]out1 << …

Member Avatar for ryan8806
0
2K
Member Avatar for maddav

Hi, Recently (today) got an assignment to take a particular code that we've done previously, and split it into 3 files: 2 .cpp files and a header file. Now, i believe i've done it correctly, but the only thing that's throwing up errors is the use of friend for overloading …

Member Avatar for maddav
0
3K
Member Avatar for picabodaddy

Trying to learn Java on my own with the book "Starting out with java" The question is this Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: circles rectangles cylinders (it gives the formulas for the are of them) Because the …

Member Avatar for vchandra
0
3K
Member Avatar for Macbeth

Hi, coders. I have to overload operators +, *, =. Object L3(default "abc") must be smth like this "aabbcc"(operator*; double each symbol of the string). Then I must concatenate Object2 and Object3(operator+), and initialize Object1(operator = ). I have strange errors error C2296: '*' : illegal, left operand has type …

Member Avatar for Banfa
0
186
Member Avatar for TimeFractal

Hello, I need to simulate a stream which behaves exactly like a ostringstream, except when handling objects of type color. What is the best way to do this? [code] user.display() << color() << "Name: " << color(color::Red) << setw(10) << left << str_name << endl << color() << "Date: " …

Member Avatar for TimeFractal
0
2K

The End.