39 Topics
|
|
|
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 … |
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 … |
|
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 … |
|
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& … |
|
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 << … |
|
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 … |
|
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 … |
|
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 … |
|
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: " … |
The End.