No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
Hi, I was given this class member function that overloads the == operator. I don't understand it. Please could you help me understand it? Here is the class [CODE]class Word { public: // constructor Word(const string& word); // overloads is-equal-to (or equivalence) operator - this is very useful for testing, … |
|
Hi there, I have been trying to figure out the common recursion problem given in e.g. 6.42 in the following link: [URL="http://net.pku.edu.cn/~course/cs101/resource/CppHowToProgram/5e/html/ch06lev1sec28.html"]Towers of Hanoi[/URL]. After a few hours I still can't figure it out, even though I've got the code: [CODE=cplusplus]#include <iostream> using namespace std; // num disks void Towers(int … |
|
Hi there, I'm having a problem with the code below: [CODE]#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void setArray( float [], const int Size ); void displayArray( const float * ); int main() { const int arraySize = 20; float array[ arraySize ]; // Initialise the array: setArray( … |
|
Hi there, Say I have the following while loop, that loops on the condition that a lne (a string) is received from a file: [CODE]while ( getline( inData2, line ) ) // Increment rows till none left { if ( !line ) { cout << "No data entered. Please enter … |
|
Hi, I am having a problem with the following function: [CODE]void calcEnergy( vector< vector<double> > &Energy, vector< vector<double> > &Data, const double Constant ) { double Time = 6; // store the change in time double energy ; // Temp variable to store energy double v1,v2; for ( size_t i … |
|
Hi there, Say I have created an ifstream object in main(): [CODE]ifstream [B]inData[/B]; // Create new input file stream object inData.open( "input.dat" );[/CODE] How could I then pass this object to a function, instead of having to recreate it there? I.e. what would the argument and parameter look like? Thanks … |
|
Hi there, I am having a problem with the following code: [CODE]#include <iostream> #include <string> #include <fstream> using namespace std; int findRows( string line ); int main() { string line; int rows = findRows( line ); cout << "Number of rows: " << rows << endl; } int findRows( string … |
|
Hi there, The Wallis product is defined here: [url]http://en.wikipedia.org/wiki/Wallis_product[/url] I am having a problem with the following code, which attempts to approximate the product: [CODE]#include <iostream> #include <cmath> using namespace std; int main() { int n = 2; // initialise top counter as 2 for the first two terms int … |