49,757 Topics
| |
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] … | |
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? | |
[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: … | |
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 … | |
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 … | |
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 … | |
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 ;) … | |
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] | |
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], … | |
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 / … | |
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 … | |
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> … | |
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! | |
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) … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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> … | |
This is a stupid question, but for the life of me, I cannot remember how to create the "Or" symbol in code....(the two vertical lines...)...how do I do it? | |
I tried to create an array that would increase its own size depending on the user's action. For example: The user types the name of one contestant, the array contains only one element (the name), later the user enters another contestant, the array becomes an array of 2 elements, each … | |
Hi, I am learning inheritance and abstract base classes. I need to define an abstract base class (ABC) that provides interfaces, and a derived class (directly from the ABC) that provides the implementation. The derived class may need additional member functions and variables (both, public and private). Using a pointer … | |
Hello, I just wanted to say Something about OS I read the one march 2004 topic But if I read a book on C and c++ Will it show me how to do like programs Is there a site that shows me how to make a OS? | |
need help, what I need to do is have the status function run before each withdrawl to let the user know if the account is active or inactive. Active = balance > 25, if account balance <25 then no withdrawls can occur. I have the following: #include <iostream> #include "Savings.h" … |
The End.