-
Replied To a Post in Change a 4 character string with a 1 character string
Whats is `sqrt` in `modifiedExpr.replace(modifiedExpr.find(sqrt),sqrt.length(),"#");`? Is it a string? You should be able to do: string sqrt = "sqrt"; size_t pos = 0; while((pos = modifiedExpr.find(sqrt, pos)) != std::string::npos) { … -
Replied To a Post in Finding 'sqrt', 'log' and 'abs' in a expression
You have: bool Expression::IsOperator(char C) { if(C == '+' || C == '-' || C == '*' || C == '/' || C == 'sqrt' || C == 'log' || … -
Replied To a Post in Using replace() with original and modified expressions
@iamthewee The OP's function uses var and val. I don't think it would compile if they had the same name. I think that would be a type redeclaration error. -
Replied To a Post in Using replace() with original and modified expressions
If you need to be able to change a variable at any time why not store everything as tokens? Then the token for a variable can hold onto the variable … -
Replied To a Post in area of a circle
`A=πr^2` -
Replied To a Post in Using replace() with original and modified expressions
When the function exits are you updating the original expression to be the modified? If not then this will always happen. I think you need to store the modified expression … -
Replied To a Post in Using replace() with original and modified expressions
`modifiedExpr = originalExpr;` needs to be moved outside the loop. The way you have it now is every time the loop is executed `modifiedExpr` becomes the original again erasing what … -
Replied To a Post in Procedure of learning C++
ruberman I would have to disagree that you have to learn C to learn C++. Saying C++ is C with classes really diminishes what C++ is. You have templates, exceptions, … -
Replied To a Post in Procedure of learning C++
Well if you have never used C++ you really should learn how to use it before you try to use it. Otherwise how do you know how to start coding … -
Replied To a Post in Another way to convert an int to a string instead of using itoa
the `startingExpr` member of your Expression class holds the final value which is `5 + 3 + sqrt 25 - 3` -
Replied To a Post in Another way to convert an int to a string instead of using itoa
void Expression::instantiateVariable(char var_, int val_) { cout << startingExpr << endl; instantiateVariable(startingExpr,var_,val_); } Becomes void Expression::instantiateVariable(char var_, int val_) { instantiateVariable(startingExpr,var_,val_); cout << startingExpr << endl; } If you want … -
Replied To a Post in Another way to convert an int to a string instead of using itoa
I take you have something like `"x + 5"` and you want a function that searches the expression for the variable and replaces it with a number. To do that … -
Replied To a Post in Bus ticket reservation system
And your qustion is? -
Replied To a Post in inheritance c++
Honestly I never use the wizzard. I just write the code. -
Replied To a Post in bit operator << with char
Well `<<` is the shift bits to the left operator. Since the default value for `FOO_ENUM` is 0 you get: unsigned char sideFilter1 = 1 << FOO_ENUM; =unsigned char sideFilter1 … -
Replied To a Post in inheritance c++
Go to Project -> Add Class. That will create a new class and bring up the class wizzard. -
Replied To a Post in Simple Payroll (Debugging) c++
Are you trying to enter a name like "Nathan Oliver"? if so you need to use [getline()](http://www.cplusplus.com/reference/string/string/getline/) and not [>>](http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/). Don't forget to [flush the input stream](http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream) when mixing `getline()` … -
Replied To a Post in Got a little problem :(
Line 6: should be using a string not an int. `string nap;` Line 10: get rid of the string decleration. `if (nap == "hétfő")` That should clear up some of … -
Replied To a Post in String not naming a type
`string` and `stringstream` need to be qualified with `std::` or you need to put `using namespace std;` in your code after you includes. -
Replied To a Post in Data from Text File into Dynamic Array
When I read an unknown amount of data from a file I will use the following std::vector<int> data; ifstream fin("sampleData.txt"); int temp; // used to store the data from the … -
Replied To a Post in declaration of main in c++/c++11
[Here you go](http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c). personally unless I need or want to support command line arguments I just use `int main()` -
Replied To a Post in pair template in c++11
Try p = make_pair(112,"one-one-two"); -
Replied To a Post in C++ - Create Class Object dynamically through cin
Okay. And you resurected an 8 month old thread becuase...? -
Replied To a Post in Problem with deallocating string 2d dynamic array
Line 35 should use rowSize not colSize. This is because you are stepping through each row and deleting all of the columns. -
Replied To a Post in Finding a string within a string (Needle and Haystack c++)
If you call transform on both haystack and needle and have them both lower case then it should work. -
Replied To a Post in Finding a string within a string (Needle and Haystack c++)
You need to transform the strings to all lower case. You can use this to do that. string input = "AbAbbAbBBaAA"; transform(input.begin(), input.end(), input.begin(), ::tolower); -
Replied To a Post in Finding a string within a string (Needle and Haystack c++)
The way I have done it is like: size_t pos = 0; int counter = 0; // loop untill substrng is not found. while ((pos = strng.find(subStrng, pos)) != std::string::npos) … -
Replied To a Post in Program skips second loop of inputting with cin.
You need the ingnore outside the while loop like I posted. When cin gets the EOF it set the EOF flag which causes `cin >> input` to be false and … -
Replied To a Post in Program skips second loop of inputting with cin.
Do `cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n')` before the clear just to make sure the buffer is empty. I think there is still a newline in the buffer. You will need to include <limits> … -
Replied To a Post in Program skips second loop of inputting with cin.
I bet you need to clear the stream after the first while loop. Add `cin.clear()` in between the two while loops. -
Replied To a Post in Search in File Handling in c++
I would suggest that when the program starts you read in all of the data in the file and load it into an collection of "Movie Records". Then you can … -
Replied To a Post in c++ write and read() functions usage in files
Generally speaking read and write are used to read and write binary data in files. Normally that goes hand in hand with [serialization](http://www.parashift.com/c++-faq/serialization.html). -
Replied To a Post in Is there really any use for learning C++?
Dido. C++ support so many different programing paradimes that can be related to so many different languages. -
Replied To a Post in Help with STL
You can do this much easier with the STL. Here is how I normally read a file by line and separate by word: std ifstream fin ("file.txt"); std::vector<string> docWords; std::string … -
Replied To a Post in Not able to read the first key value pair in map
Change `props.emplace(std::pair<string,string>(tokena,tokenb));` to `props.insert(std::pair<string,string>(tokena,tokenb));` -
Replied To a Post in Help with STL
Something like this would work vector<string> doc; vector<string> skipWords; // fill doc and skipWords from there files. When doing so convert each word to lower case. Remove any puctuation as … -
Replied To a Post in Creating custom array class
becuase the functions are templated so you need to specify in the class what template to use. -
Replied To a Post in Creating custom array class
For your case I think it would be like the following like the following template <typename el> class Array { public: friend std::ostream & operator<< <el>(std::ostream& ouput,const Array& a) friend … -
Replied To a Post in Creating custom array class
Since you do not have `using namespace std;` in your code you need to prepend `std::` to everything you are using that is part of the STL. So `throw invalid_argument("Array … -
Replied To a Post in A c++ program that calculates th esum of odd numbers between 3 and 35
do { your_homework(); } while (in_school) -
Replied To a Post in Creating custom array class
Depending on the compiler you are using you might have to have everything in the header file instead of splitting it up like a normal class. I would put everything … -
Replied To a Post in problem insertion sorting in arrays
As an FYI prerequisite programing classes are very important. Everything you do in higher level programing classes builds off of them. -
Liked / Shared Check if a smaller 2d array exists in a bigger one
Hi , I have a small 2d array and I want to check if it exists in a bigger 2d array. I have coded it but I don't know what … -
Replied To a Post in No matching function for call to Nvector::Nvector(int)
Post the code that you have now. -
Replied To a Post in No matching function for call to Nvector::Nvector(int)
Line 6 in you .cpp is `Nvector::Nvector(int Size) : velicina(Size);` it should be `Nvector::Nvector(int Size) : velicina(Size)` -
Replied To a Post in Start running the C++ code with visual studio 2010
Can you show it with the file extensions shown? -
Replied To a Post in Writing a stack module
So rework the class to be a struct. -
Replied To a Post in Writing a stack module
I would suggest you work on getting part one working first and then go on from there. -
Replied To a Post in Writing a stack module
@ tinstaafl You wouldn't write a function like `void push (stack *, std::string)` if the function is a member of the class. You would write it like `void push (std::string)` … -
Replied To a Post in Writing a stack module
It looks like that is how your instructor wants this done. Why he would want it like this I have no idea. IMHO he should be cited for endangering the …
The End.