45 Topics

Member Avatar for
Member Avatar for can-mohan

Hi All, in below class i wanted to have two friend function(overloading) one with default argument and other is without default argument. but during compilation it gives error. could you let me know how to fix (overload) this by not changing the function name , argument type or number of …

Member Avatar for rubberman
0
286
Member Avatar for Rootz

I am not sure why my program isn't writing to the text file. When I start the program it tells me that the file opens. Then I call the functions that are inherited from other classes and I would assume that it would write to the file and then display …

Member Avatar for Ancient Dragon
0
245
Member Avatar for sparky58

This assignment asks to add some code from to a previous assignment I had. I have been confused about this overload operators alot and im confused on how to do it in my code any help with this will be good A) overload the >> operator to allow for reading …

Member Avatar for Banfa
0
386
Member Avatar for Elixir42

Dear Kind DaniWebbers, I am trying to overload the fstream operators (ofstream/ifstream), so that I can save a class to a 'Binary' file and also display it with cout. But the ways in which each need to be implemented is different. Please can you show me how to define different …

Member Avatar for vijayan121
0
4K
Member Avatar for Labdabeta

Hello, I have a particular set up of cast operators and constructors which is leading to a compile-time ambiguity error. I am wondering if somebody can explain why this is happening and what can be done to fix it. For example, here we have 2 classes: class A { int …

Member Avatar for Labdabeta
0
312
Member Avatar for Hey90

I have been told it is good to overload the stream extraction operator to load data from a file. Would I simple use this in my class: friend ifstream &operator>>( ifstream &input, Class &C ) { input >> C.variable1 >> C.variable2 >> C.variable3; return input; } What are the advantages …

Member Avatar for deceptikon
0
432
Member Avatar for challarao

Hi all, A question asks me to write overloading functions to square,circle ,rectangle and triangle.... But since the square and circle have only one parameter I had to change the parameter of area of circle to double...... Is this the only way to accomplish this..... Are there any other ways …

Member Avatar for stultuske
0
193
Member Avatar for darkeclipse8

---------------------------------------------TSet.h------------------------------------------------------ #include <iostream> using namespace std; template <class V> class TSet { public: TSet(); TSet(int size); ~TSet(); void add(V new_item); void remove(V item_to_remove); int num_of_items(); bool isFull(); bool is_item_in_set(V item); friend bool operator==(const TSet<V>& left, const TSet<V>& right); friend bool operator!=(const TSet<V>& left, const TSet<V>& right); friend ostream& operator<<(ostream& outs,const …

0
151
Member Avatar for daniel.krishnasamy

Please Help me with this Date Operation Program. I think that this works....yet! Thanks #include <iostream.h> #include <conio.h> int a[7]={1,3,5,7,8,10,12}; int b[7]={4,6,9,11}; class manipdate { int date; int month; int year; public: int d,m,y; void getdata() { cout<<"\n\n Date : "; cin>>date; cout<<"\n Month : "; cin>>month; cout<<"\n Year : …

Member Avatar for Ancient Dragon
0
540
Member Avatar for phfilly

Hi -i've started using netbeans and compiling in it recently and I'm not sure what the problem is here. Not sure if it isn't reading the Element.cpp/.h files while building/running the main.cpp In my main: Element a, b(5); cout<<(5+b)<< endl; Then in the .h: Element operator+(const Element&obj); And in the …

Member Avatar for rubberman
0
163
Member Avatar for SCass2010

Hi everyone, At the moment I'm trying to create a class that contains a DOMNode* pointer, something like this class MyDOMNode { public: MyDOMNode (DOMNode* node) : mDomNode (node) { } bool operator== (const MyDOMNode& rhs) { if (mDomNode == rhs.mDomNode) return true; return false; } bool operator!= (const MyDOMNode& …

Member Avatar for deceptikon
0
159
Member Avatar for coutnoob

Hi again and thanks in advance !Any help would be very appreciated cause i'm having a test tomorrow and i need some help! So i wanna have a class called Bag and a subclass Set.In bag we have 2 constructors, an insert function , getsize function , getsum (which adds …

Member Avatar for VernonDozier
0
222
Member Avatar for greatman05

Hello. I need to create a program to manipulate polynomials. It contains basic evaluation, addition, subtraction and multiplication of polynomials. Right now, I'm working on overloading the '+' operator to add two polynomials. While the function adds the two polynomials together correctly, when it goes to output through the overloaded …

Member Avatar for greatman05
0
2K
Member Avatar for aparichit4evr

Hello friends...I'm having confusion about binary operator overloading in the following program. The question goes like this. Qn. Create a class time with two member variables as hours and minutes of integer type,write default,parameterized and copy constructor. Overload necessary operators to compute T3=5+T1+T2, where T1,T2 and T3 are time objects. …

Member Avatar for tungnk1993
0
276
Member Avatar for bennetk2

I can't figure out what this error is saying. Error: C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp||In function 'bool operator==(const statistic&, const statistic&)':| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|225|error: passing 'const statistic' as 'this' argument of 'float statistic::sum()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|225|error: passing 'const statistic' as 'this' argument of 'float statistic::sum()' discards qualifiers| C:\Users\Kyle\School\CS 372\Statistician\Statistician.cpp|226|error: passing 'const statistic' as …

Member Avatar for gusano79
0
332
Member Avatar for corby

im trying to overload the operator+= and use that to implement operator+ in my string class. i keep getting a segmentation fault when i try to evaluate something like s1 += s2 where MyString s1("");and MyString s2("hello"); any suggestions as to why this is happening? this is my operator+= function …

Member Avatar for corby
0
179
Member Avatar for nikitadurgude

[CODE]#include <iostream> using namespace std; class bike { public: bike () { cout << "Bike: no parameters\n"; } bike (int a) { cout << "Bike: int parameter\n"; } void color(int a,int b) { cout<<"Inside Bike Color"<<endl; } }; class ducati : public bike { public: ducati (int a) { cout …

Member Avatar for Narue
0
210
Member Avatar for atiyehjoon

hello my dear friends I have read a book that was simple to learn c++,recently But in operator ovorloading threads ,I dont underestand many example for ovoreloading in another books & booklets for example : in the example below 1 // Fig. 11.3: PhoneNumber.h 2 // PhoneNumber class definition 3 …

Member Avatar for mike_2000_17
0
211
Member Avatar for tvm78

so i have this program written and i am getting a seg fault and the stack said in operator<<. I have no idea how to fix this...It is due in thirty minutes if someone can please help me asap. Here is where i think the problem lies: [CODE]#include <iostream> #include …

Member Avatar for Ancient Dragon
0
213
Member Avatar for tvm78

So I'm trying to write a program that is due tomorrow. I am trying to overload operators and dealing with template classes. I have everything written already but keep getting this error whenever i try to compile the driver file: NOTE: proj4.cpp has #include "box.h" and box.h compiles fine, but …

Member Avatar for NathanOliver
0
270
Member Avatar for Idestruction

I am doing this assignment for my C++ class, and we have to instantiate 4 objects of the Student class, set the data members and then sort them according to the GPA variable. Ive whittled down the errors to just one, and I am stumped. Here is the error: error …

Member Avatar for Idestruction
0
336
Member Avatar for mullerfourie

Hi, I need to finish a assignment on operator overloading but this one piece of code doesnt seem to make sense.. in my int main() i have int main() { Element a, b(5), c(7), d; cout << (5+b) << endl; this is just part of it, I have already implemented …

Member Avatar for mullerfourie
0
210
Member Avatar for fibbo

Hey guys! I hope what I'm about to do is not frowned upon :) I just would like some input/critics/heads up on my class definition and implementation I did for my project. I am by no means a trained programmer and I doubt my coding style is very good so …

Member Avatar for fibbo
0
213
Member Avatar for toneranger

I'm reading a big csv file into a data structure defined as such: [CODE]struct PriceInfo { double Open; double High; double Low; double Close; unsigned int Volume; unsigned int Time; std::string Date; };[/CODE] So somewhere in my main function, I have this line: // read contents of datafile by overloading …

Member Avatar for danb737
0
578
Member Avatar for mwmnj

Hi, I am working on an exercise in operator overloading. I've created a matrix class and I am supposed to overload operators so I can do arithmetic on matrices efficiently. My directions say that I am supposed to make two matrix arrays using the class constructor that has 2 parameters …

Member Avatar for Saith
0
259
Member Avatar for stkarnivor
Member Avatar for mike_2000_17
0
574
Member Avatar for Labdabeta

Is it possible to overload an operator for a built-in type? And if so what is it's syntax? EG: [CODE]//Use of overloaded operator^ for types double and double (assuming it is overloaded for exponent): double a=10.0; double b=2.5; double pow=a^b;//pow is approximately 316.22....[/CODE]

Member Avatar for L7Sqr
0
174
Member Avatar for Vindal

Hello everyone, I am having some problems with my code and allowing it to do what I want. I need within main to have the account balance from my class to be allowed to change value through "transactions" adding negative numbers for a withdraw and positive numbers to put in …

Member Avatar for abhimanipal
0
195
Member Avatar for PdotWang

This is an answer to a question in C++ area. [url]http://www.daniweb.com/software-development/cpp/threads/355232[/url] It should be ready to be modified to code in C++, C#, or Java, because VB.Net is fully OOP. Even though it can be used for vectors, you may still want to modify it to a Vector Class.

Member Avatar for spixy
0
709
Member Avatar for Labdabeta

I am working on making a 'safetype' abstract class, which will have a complete set of pure virtual operator overloads to help make sure that a class inherited from it is safe to pass to virtual any function. The problem is that I don't know the syntax of a pure …

Member Avatar for Labdabeta
0
239

The End.