49,761 Topics

Member Avatar for
Member Avatar for merse

What is the compound assignment operator overloading syntax? I cannot find on the web. How can for example overload operator+= ? I know that it has to be a member function but what has to be its return value? reference?

Member Avatar for Narue
0
88
Member Avatar for aq5

Hey i recently got set a project to design a c++ connect four (four in a row) program on the console or using GUI. It only has to be Human vs Human, which is prolly sumthing a lot of you hav seen or done b4. I draw a blank with …

Member Avatar for Murtan
0
455
Member Avatar for Loner7

I'm working on a University assignment at the moment (a final assignment). I've normally been able to figure things out, but the teacher's thrown us a curve ball by making us use <fstream>. We've only had one lecture on it which covered [I]outputting[/I] a file, but nothing really handling taking …

Member Avatar for UberJoker
0
111
Member Avatar for BobRoss

I'm trying to finish up this little shift cipher I'm writing so I can encrypt the text files on my flash drive in case the drive becomes lost or stolen. It simply reads line by line from a plain text file, encrypts each line and outputs the lines to a …

Member Avatar for BobRoss
0
159
Member Avatar for theeurostick

In my code i got two compiling errors that i cant fix one is mared by (97) and the other is marked by (213) here is the code include <iostream> #include <iomanip> #include <string> #include <fstream> using namespace std; struct skater { string fName, lName; int entry; double score[5]; double …

Member Avatar for Lerner
0
275
Member Avatar for merse

People used to use reference in operator overloading like this [CODE] Compex operator+(const Complex& c1, const Complex& c2); [/CODE] because its good for reference and static data also? (c1, c2 can be complex or complex reference also? or mixed too) Since [CODE] Compex operator+(const Complex c1, const Complex c2); [/CODE] …

Member Avatar for Narue
0
111
Member Avatar for merse

I naturally included [CODE] #include <iostream> using namespace std;[/CODE] but the following overloading not works [CODE]friend ostream& operator<<(ostream& stream, mystruct& x); [/CODE] just if I included std:: [CODE]friend std::ostream& operator<<(std::ostream& stream, mystruct& x); [/CODE] Why it is necessary?

Member Avatar for merse
0
100
Member Avatar for Ashe_Aqua

[CODE] #include <iostream> #include <string> #include <cmath> #include <conio.h> #include <cstdlib> using namespace std; class animal_game{ public: string name(){}; int leg (){}; }; //-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* class bird : public animal_game{ public: string name () {return (" Bird ");} int leg () {return (2);} }; //-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* class fish : public animal_game{ public: …

Member Avatar for Ashe_Aqua
0
67
Member Avatar for CppFTW

Hi, does anyone know why I am getting these error messages? I'm using Code::Blocks IDE and MinGW(GCC) compiler. I included boost (v1.39.0) libraries already. I can use them correctly with #include <boost/lexical_cast.hpp> Also, I defined BOOST_NO_DEPRECATED [CODE]#include <boost/filesystem/operations.hpp> #include <string> using namespace std; int main() { //The meta data file …

Member Avatar for kevint77
0
493
Member Avatar for tak9

Hi, i have a lot of errors on this and am not sure how to fix it. This needs to be turned in in 2 hours so all help is needed =)). Description: Design and implement an application that creates a histogram that allows you to visually inspect the frequency …

Member Avatar for Nick Evan
0
159
Member Avatar for samweb$

Hi Everyone, I have a program built on VS 2005 which compiles fine, and when I execute the same, it runs as expected. But i see memory leaks being detected by tools like (Visual Leak Detector, Glow Code etc..), Below is the block of code for your reference. void Argument(const …

Member Avatar for samweb$
0
87
Member Avatar for Stefano Mtangoo

I don't want to know each and everything in C++, but I wan't to know what do I need to be able to Code a good big app like Notepad++? I mean what it takes to be a best C++ expert? (Or how did the Ancient Dragon became expert ;) …

Member Avatar for mrnutty
0
348
Member Avatar for kavourdoukos

1)How can i delete the memory allocated if i have allocated dynamically through "new" like that: classA** instances; instances=new classA*[5]; for(int i=0;i<5;i++){ instances[i]=new classA;} 2)How can i pass arguments on the constructor while i am allocating memory in this way?: classB* instances; instances=new classB[5]

Member Avatar for kavourdoukos
0
84
Member Avatar for PDB1982

Alright....this is a mess, but it works (compikes) correctly....how would I create a function (probably using "switch") to return a grade based on the averages found in CalculateAvg? [code] #include <iostream> #include <iomanip> #include <fstream> #include <string> using namespace std; double CalculateAvg (ifstream& students, string studentid[60], string fname[60], string lname[60], …

Member Avatar for jonsca
0
120
Member Avatar for timlo

Hi, I'm trying to find a way to extract numbers from a text consisting of words and numbers but have no idea how to do it. The numbers can be larger than one digit and should be able to be manipulated by common math operators like +, - and / …

Member Avatar for timlo
0
4K
Member Avatar for llemes4011

I'm somewhat new to C++, and this question has been nagging at me. Is it more efficient to use a Pointer, or an actual object? Here's an example: [CODE] class SomeObject{ public: SomeObject(); /* Other methods */ }; int main(int argc, char **arcv){ SomeObject *ptrObj = new SomeObject(); // Do …

Member Avatar for Narue
0
163
Member Avatar for luvsom

I have this code that was done using pass by reference but now all the pass by references need to be changed to pass by pointer. Im not sure how to do this going back and forth between the functions. Here's what I have so far. [CODE]#include <iostream> #include <cmath> …

Member Avatar for luvsom
0
107
Member Avatar for Stefano Mtangoo

Hi there, please point me to decent 2D plotting library. Compatibility with QT/wx is an added advantage. Oh! I forgot to mention it should be free!

0
63
Member Avatar for RehabReda

hi guys i get wrong answer in this [URL="http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=8&category=3&page=show_problem&problem=100"]problem [/URL] and i don't know why please if any one know or can help please share it [CODE]#include<iostream> using namespace std; #include<string> int EditDistance[30][30]; int Tracing[30][30]; string FirstString,SecondString; int NoOfDeletions , NoOfAdditions; int FindMin(int a,int b,int c,int i,int j) { if(a<b&&a<c) …

Member Avatar for RehabReda
0
163
Member Avatar for merse

Whats wrong with the folowing simple sample? [CODE]struct mystruct { double x, y; mystruct(double z) { x=z; y=z; } }; template <class Real> class myclass { public: Real x; myclass(Real x) { this->x=x; } }; int main() { mystruct s(1.,2.); myclass<mystruct> obj(s); return 0; }[/CODE] The error message look for …

Member Avatar for jonsca
0
103
Member Avatar for zaraf

Dear All, Lately I had been using a color sensor to read some colors in terms of RGB and XYZ values. The sensor is supplied with a GUI on which I could view the results. The sensor consists of a chip with a microcontroller (i dont know which one) and …

Member Avatar for Premlal
0
111
Member Avatar for rahul8590

Its been a while i have been writing sequential programs . I have started working on parallel programming using C++ . Since to run those parallel programs in several machines isn't a feasible idea for me , i was wondering if there exist any parallel program simulator which executes parallel …

0
79
Member Avatar for jgelderloos

im working on a function for a custom list class that writes all the items of the list to an output file. However i keep getting this error: no match for 'operator<<' in 'fout << nodePtr->List::Node::myItem' and error: no match for 'operator<<' in 'fout << ' '' i think ive …

Member Avatar for tkud
0
83
Member Avatar for prominababy

I'm trying to make this simple dictionary using hash table and struct. basically i restore the information in the struct and put the struct into an array of pointer. but my program seems buggy. this program is not complete yet, so there are still some function missing. but with the …

Member Avatar for jasonline
0
91
Member Avatar for cpp_fanatic

I have class A and class B: template<typename T> struct A { T data; ... }; template<typename T> struct B { T data; ... }; I can do the following: B<A<int> > b1; B<A<MyOtherType> > b2; But, these lines are so ugly and I want to make special type. I …

Member Avatar for Premlal
0
97
Member Avatar for crystality

Hi! I'm trying to implement an optimization idea for Dijkstra's algorithm for homework. This is the optimization idea that they want us to implement: [INDENT][B]Idea 3. [/B]Many of the vertices have exactly two neighbors. If a vertex [I]v[/I] has exactly two neighbors [I]u[/I] and [I]w[/I], then you can replace the …

Member Avatar for crystality
0
170
Member Avatar for mitchstokes225

Here is the Assignment: Write a C++ program that takes in 2 binary numbers (up to 16 bits each). Each number is stored in an array with the individual bits stored one in each element of the array. The program should then add the binary elements one bit at a …

Member Avatar for mrnutty
0
96
Member Avatar for shmeeps

Basic, I'm trying to read in a file that has lines of data, where each set is on a new line, and each variable is separated by whitespace, save for the name, which can have multiple white spaces. Here's basically my code, the parts that matter. [code] #include <stdio.h> #include …

Member Avatar for shmeeps
1
178
Member Avatar for UberJoker

Hey Guys. Im having a hard time figuring this out. I realize there are a bunch of topics out there discussing this problem but I couldn't find anything that was helpful to this particular situation. [CODE] #include <iostream> #include <string.h> using namespace std; typedef char charType[4]; int main() { char …

Member Avatar for UberJoker
-1
1K
Member Avatar for Stivdion

i Am beginner to c++, so bear with me i can seem to fix these errors error c2109 subscript requires a pointer or arrays [code=cplusplus] //Stephen Igbinedion //CMPS //Due Date; Dec 4th 2009 //Programming Assignments 6 (Final assignment for CMPS 1043) //This Program orders a set of integers. #include <iomanip> …

Member Avatar for Stivdion
0
230

The End.