-
Replied To a Post in OK I need help on a homework
I would worry about line 31 : f`or (int I = 10; I >= 0; I--)` When you read in the data for (int I = 1; I <= 10; … -
Replied To a Post in Inner-Join on two sorted C++ vector<int>'s
This method seems strange to me . The first thing that is obviously wrong is these lines: while((*bIter)<(*aIter)){ bIter++; } What happens if bIter is at the last position in … -
Replied To a Post in Urgent C++ Beginner Problem: Program containing arrays and menu
Doesn't matter which method you use -- pointers and new (remembering the delete when you have finished with the array) is perfectly fine, however, so is declaring three arrays of … -
Replied To a Post in Arrayclass for integer and float types.
Tiny typo -- Line 38 : `s.setval(5.1,0);` Should have been` s1.setval(5.1,0);` There are ways round this kind of error (scoping the two test etc) but in reality better naming is … -
Replied To a Post in Histogram
I agree a bit with rproffitt, but without actually running the code I noticed the following: line 51 : `elements[x++]= M[i][j];` x is not initialized. Might and might not start … -
Replied To a Post in aggregation impelemtation in c++
The problem here is ownership and responsibility. The aggregate class would normally take ownership of the object being passed to it. [Sometimes that aggregate class would build the object via … -
Replied To a Post in Insert random number
Your code is nearly correct but I am not 100% sure that it is giving your what your want: So here is your code with some comments -- just to … -
Gave Reputation to Schol-R-LEA in A historical question about compilers
What Labdabeta said is correct, but a bit skimpy, so I'll give you a bit more detail. For the first five to ten years of programmable electronic computers, programming was … -
Replied To a Post in 3d space vector
You seem to be asking a lot of questions about developing a C++ 3D geometry system of some sort. I think it would be a lot better to show us … -
Replied To a Post in 3d space points
Sorry but I really don't like this piece of code from skaa. The problem for me is that double precision numbers have floating point error, so you really don't know … -
Gave Reputation to Moschops in Game on c++
How much programming experience do you have, and with what languages? C++ is a low-level language; there are various definitions of what this means, but for the purposes of this … -
Replied To a Post in A problem with acos()
The chances are that your error is actually the accuracy of the return value from the dot product. With floating point calculations you often get a little bit of an … -
Replied To a Post in Need help in c++
The problem here is (a) the typo error with write `*num1= num2;` rather than `*num1=*num2;` (which doesn't actually affect the problem). And (b) what you are defining by const. Let … -
Replied To a Post in Inputting numbers into matrix, please help
NullPtr is 100% correct -- just a litle brief I think! Your question is what is wrong with this code. So as was pointed out the error lies in the … -
Replied To a Post in Delete an item from array with algorithm
I am really guessing here because you don't tell us what you expected and what you got. But maybe you got no output -- if that is the case was … -
Replied To a Post in how put a class function name on lambda parameter?
Nothing complex just a typo/minor miss-understanding. You wrote this: property <string> caption{std::bind(&tooltip::GetCaption, *this),std::bind(&tooltip::SetCaption, *this, std::placeholders::_1)}; Note the *this , that should be just : this. You are trying to binding … -
Replied To a Post in Project Euler - 09
Fundermentally, the loops are highly inefficient. You have the condition that a+b+c == 1000, so why not loop on a and b BUT calcuate c. Second you can limit the … -
Replied To a Post in Run - length - encoding.
You have three mistakes: (a) Your output is outside of the loop, you need to output each time that you get a new letter. (b) you don't output the letter … -
Replied To a Post in how use my class on function parameter?
No you don't HAVE to add const, but either you should because that is what you intended [and the compiler can make you faster machine code] or it is not … -
Replied To a Post in how use my class on function parameter?
First of all I don't think I can tell you what is wrong to fix your current bug.. but here are a few thoughts, and I think we need to … -
Replied To a Post in hash table
The principle of this type of hash map is that when two objects have the same key they are stored in the hashmap using a linked list. i.e if you … -
Replied To a Post in addition and subtraction
There are several problems with this code : (i) you are using double's which can represent non-integer numbers. The problem with that is if you say `if (a==b) ` but … -
Replied To a Post in Knight Tour Stack
The quick solution to this is to actually know the algorithm that the knights tour works on. It can be shown that for any size square and rectangular board (above … -
Replied To a Post in C++ problem(again)
That is a LOT of if statements for a nice output. Acutally there is a quicker way to do it [ assuming that you don't want to use printf or … -
Replied To a Post in Menu using Switch
It is unlikely that you really want a switch statement. The problem is basically a set of decision based on two different criteria: age/gender. That ends up as a two … -
Replied To a Post in Write 2D array into a binary file
I think you have made another mistake: Consider the line of code f.write((char *)&array[i][j],sizeof(array)); Now for your test example you have an array of [3][3], which if we assume you … -
Replied To a Post in Incrementing member of a pointer to structure, increments remaining members
Have you looked to actually see what you have done with memory allocations. It seems that you have the following : rol=(struct roll*)malloc(t1*sizeof(struct roll)); yr=(struct year*)malloc(t2*sizeof(struct year)); mn=(struct month*)malloc(t3*sizeof(struct month)); … -
Replied To a Post in solving polynomial equations of degree 3 with C++
Some of the things you will see are that you have looped over the end of your arrays. e.g. line 18 and 36. You have written: double y[21]; // stuff... … -
Gave Reputation to mike_2000_17 in Array resize - enhance the efficiency
What is really important is to resize by an amount that is proportional to the current amout in the array. Typical factors vary from 1.25 to 2. The reason why … -
Replied To a Post in help needed with hangman project
The problem with this code is firstly that it just doesn't work, but much more problematic it shows some little mis-understandings in the basics of type conversion. First of consider … -
Replied To a Post in Random Number
Sorry but you have steped into one of those nasty legacy areas from C. There exists a function [in stdlilb.h which is included via cstdlib] `long int random()`. Thus the … -
Replied To a Post in pointer
Memory leaks in C++ are about balance and understanding scope [a bit]. First of the fundermentals: for every allocation there must be an equal deallocation. That is about it. Consider … -
Replied To a Post in Definition and Purpose of visual SALIENCY
The obvious uses are all around -- I will list a few: Control room of a complex system (e.g. a nuclear reactor). In a typcially control room, you want the … -
Replied To a Post in grow array
I think the code should have been : if (size==next_element) { // THIS Function doesn't work yet p_values= growArray(p_values,size); } p_values[ next_element++ ] = val But then you will have … -
Replied To a Post in C++ : Uno Game Help!
Ok -- it compiles and that is great! Well done... However, that is were the good stuff stops [Sorry] I am not going to post a working and viable solution. … -
Replied To a Post in c++ memory problem
There really is not enough to go on here. sorry. But here is my memory error check list: (a) Have you zeroed the pointer before trying to free it e.g. … -
Replied To a Post in Classes help
It is just that you have left a trailling `'\n'` in the input stream. You can tidy that up with code like this: for (int i=0; i<MAXSTUDENT; i++) { s1[i].enterDetails(); … -
Replied To a Post in Varying substr length
Your problem is one or two things: (a) the line STOP in your input only has 11 characters in it. (b) You don't check the input size in your code … -
Gave Reputation to mike_2000_17 in template parameters as base class - incomprehensible stroustrup
Just so that people understand what this discussion is about. I'm gonna post the essential bits of code that from that section of the book. The first solution that he … -
Replied To a Post in [Error] cannot convert 'double' to 'float*'
However as well as that problem, which you can solve as suggested above. You will find that value is constant for long period of the loop. That is because you … -
Gave Reputation to Curious Gorge in Inverse result with macro #ifdef's in Poco Library
Ah, yes that does make sense. I thought I must have assumed 64bit longs meant it was a 64 bit architecture but I was not sure. Thank you! **[EDIT] ** … -
Replied To a Post in Trouble Manipulating Data through My Own Iterator
Ok there is lots and lots of little problems with this code. But before I talk about some of them, I don't understand your use of the word iterator. In … -
Replied To a Post in C++ Rainfall Program: Linked Lists
The first error is that you have a single collon (:) and then the word Rainful [line 14]. After that without Rainfall.h is would take me too much time to … -
Replied To a Post in Help with Random Number Generator please
There are a number of issure with various aspects of this coe: `int GetGuess()`, I assume is there to return the number of guesses that the player took to get … -
Replied To a Post in Numbers to roman numerals
You logic is flawed because you put == instead of >= . Consider the lines 15 -19 . while (num ==900) { cout <<"CM"; num = num - 900; } … -
Replied To a Post in Using singleton in c++
You error seems to be in the copy constructor/assignment operator of way. If you add : Way::Way(const Way& orig) : id(orig.id),name(orig.name) {} Way& Way::operator=(const Way& A) { if (this!=&A) { … -
Replied To a Post in how is this queue being implemented?
Ok this is a standard top-tail queue. Let us walk through the process of putting objects into the queue and taking them off again to see how it works: The … -
Replied To a Post in Need help with a problem
ok -- you start with some input and checking -- kind of ok -- Note that you have not checked if the user inputs that he wants 50 numbers... you … -
Replied To a Post in Prime number generator in C++ Spoj Problem..Giving Runtime Error.
There are several issues with this program that will result in problems. First off the cause of the error is likely to be the lines: cin >> end; bool arr[end]; … -
Replied To a Post in I need help with finding mode in c++
I made a slight error : the line: `if (data[i]>0 || data[i]<101)` should have read `if (data[i]>0 && data[i]<101)`. Obviously I just typed the code into the post, I didn't …
The End.