Posts
 
Reputation
Joined
Last Seen
Ranked #70
Strength to Increase Rep
+11
Strength to Decrease Rep
-2
99% Quality Score
Upvotes Received
171
Posts with Upvotes
145
Upvoting Members
100
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
74 Commented Posts
4 Endorsements
Ranked #397
Ranked #141
~288.01K People Reached
Favorite Tags

565 Posted Topics

Member Avatar for KLane

You still have a couple of design issues (bugs). In particular look at the value n. It is suppose to be the number of data items added, but actually you set it in the constructor, why not increase it each time that you add some data, and set it to …

Member Avatar for mellguth
0
1K
Member Avatar for qqwushi12345

Your problem is assuming that x1 and x2 are integers when you print them out. Additionally, a,b,c are all likely to be floating point numbers. So read them in as floats. So make your output statement [icode]printf("%g and %g\n",x1,x2);[/icode] Also you can use the sqrt function in line [icode]k=sqrt(d);[/icode]. HOWEVER: …

Member Avatar for mohanned_2
0
4K
Member Avatar for Nomar_1

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; I++) { cout << I << ")"; cin >> N[I]; cout << "\n"; } You populate the value N[1], N[2]... …

Member Avatar for StuXYZ
0
355
Member Avatar for Dean_5

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 the array. So in short I would have written something like this std::vector<int>::const_iterator aIter=aList.begin(); std::vector<int>::const_iterator bIter=bList.begin(); if (bIter==bList.end()) return 0; …

Member Avatar for StuXYZ
0
2K
Member Avatar for Rain_1

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 size 20 and filling only the first part of each. Note you need to check the user input isn't bigger …

Member Avatar for Andrew_36
0
421
Member Avatar for can-mohan

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 more important. I hate any name that can be confused with another name by one character missing/changed etc. However I …

Member Avatar for can-mohan
0
365
Member Avatar for Ghada_1

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 as 0. line 64 `elements[k] = elements[k+1];` In the first parse if elements[i] == elements [j] then this line sets …

Member Avatar for StuXYZ
0
238
Member Avatar for tonykjose

There are many many things wrong with this. Let us start with MergeSort. Ok explain [code=c++] int k = 1; for ( i=0;i<k;i++) { q = q->next; } [/code] Ok we have (A) a global variable as a loop index !! (B) a loop that never does anything more than …

Member Avatar for rcgldr
0
367
Member Avatar for can-mohan

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 a factory object -- but let us keep this simple]. So in words this is what I think you want …

Member Avatar for StuXYZ
0
218
Member Avatar for ALosh99

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 make sure: // This line sets the random number seed. // you only need this call once only in your …

Member Avatar for ALosh99
0
261
Member Avatar for homeryansta

I think the fatal error says everything [B]Disc quota exceeded[/B] I think it is time to talk very nicely to the system admin. or delete that large cache of movies.... ;)

Member Avatar for Syed Zuman
0
969
Member Avatar for Dasun_1

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 the framework you have built, and the problem domain. For example, the answer to this questions needs us to understand …

Member Avatar for StuXYZ
-1
75
Member Avatar for Dasun_1

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 [most of the time] if they are going to be equal e.g. is 1e-76 equal to 1.1e-76. This kind of …

Member Avatar for StuXYZ
0
188
Member Avatar for tgreiner

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 error, so you might be returing -1.0000000001 from your vector dot product. The quickest way to check that is to …

Member Avatar for ipswitch
0
2K
Member Avatar for jamesjohnson25

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 us start by looking at the definition of limit: const int limit=100; That says limit is 100, and the compile …

Member Avatar for aleeha.saqib.5
0
225
Member Avatar for James_47

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 line temp >> num[i][j]; Let us consider a similar expression: int a=5; int t=2; int x = t >> a; …

Member Avatar for StuXYZ
0
118
Member Avatar for hadisur_rahman

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 it because you forgot to put a std::endl in your code e.g. add line 25 : cout<<endl; The algorithm is …

Member Avatar for StuXYZ
0
162
Member Avatar for cambalinho

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 a class method pointer to a class instance pointer. If the class instance pointer is no such thing then things …

Member Avatar for cambalinho
0
192
Member Avatar for Petcheco

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 loop extent based on the idea that c>b>a. Thus a can never go beyond 333 (1000/3) and b extends from …

Member Avatar for Petcheco
0
349
Member Avatar for RKVP

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 just the number. (b) you don't deal with the special case of temp=1, i.e. you don't need to output the …

Member Avatar for rubberman
0
657
Member Avatar for zrd0808

The obvious errors are things like : In [code=c++] int stepOne(Graph &g, ListCell* l, int u) { int lowestVert = l->next->adjVertex; // Seg fault here if l is null double lowestWt = l->next->weight stepOneHelper(g,u); // THIS test is too late. if(l == NULL) { return lowestVert; } [/code] Also [code=c++] …

Member Avatar for Schol-R-LEA
0
445
Member Avatar for cambalinho

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 see the calling code for Picture. However, the following might help [hopefully!]. The key elements here are that your default …

Member Avatar for Schol-R-LEA
0
299
Member Avatar for PulsarScript

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 store say 12345 and 23456 at key number 7, then both will be stored at location 7. Now if it …

Member Avatar for StuXYZ
0
199
Member Avatar for DS9596

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 actually a=3.00000000001 and b=3.000000000000000, they are not equal. When you do arithmatic between two numbers you are certain to have …

Member Avatar for tinstaafl
0
161
Member Avatar for hellocsprogram

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 a minimum size), that simply selecting the unvisited square with the least possible open moves from it, is the optimal …

Member Avatar for StuXYZ
0
661
Member Avatar for TObannion

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 boost format etc ] #include <iomanip> // other stuff... cout<<setfill('0'); cout<<setw(2)<<hour<":"<<setw(2)<<min<<endl; cout<<setfill(' '); What that does is set the fill …

Member Avatar for TObannion
0
236
Member Avatar for DS9596

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 state switch statement embedded in another two state switch statement... uck!! What is wrong with float membershipFee; if (age < …

Member Avatar for StuXYZ
0
282
Member Avatar for Swalih

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 have 4 byte integers: `sizeof(array)` evaluates to 36. Ok so you then take each point on the array in turn …

Member Avatar for Swalih
0
3K
Member Avatar for kARTechnology

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)); da=(struct day*)malloc(t4*sizeof(struct day)); But then given that month has the structure : struct month { day* da; }; However, at …

Member Avatar for StuXYZ
0
247
Member Avatar for Luisa_1

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... for(int k=0;k<21;k++) { y[k+3]=-((a1*y[k+2])+(a2*y[k+1])+(a3*y[k]))/a0); } Note that k+3 means that k goes to 24. That will cause memory corruption. Additionally, …

Member Avatar for StuXYZ
0
2K
Member Avatar for thilinam

Hi, [icode]operator++(int)[/icode] and [ICODE]operator++()[/ICODE] are the post and pre increment signatures respectively. Note that the (int) in the post-increment does not get assigned or used i.e. you might write [code=c++] class A { public: A& operator++(int) { // do stuff here; return *this; } }; [/code] Note: You do not …

Member Avatar for pirbhat.ariya
0
239
Member Avatar for noor.ulhuda.372

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 types: By this I mean the storage for a variable or constant. Examples are int (an integer type), or double …

Member Avatar for StuXYZ
0
195
Member Avatar for chubbyy.putto

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 first of your errors. To avoid this either (a) rename your functions e.g. random100 or something (b) give it an …

Member Avatar for chubbyy.putto
0
160
Member Avatar for iamthwee

[QUOTE=;][/QUOTE] First off I commend you for investigating what I think is one of the most difficult classes to write. As always with a polynomial class, it is a case of compromises, and further improvements as scope and efficiency are improved. There are a few aspects that I think the …

Member Avatar for parisa_hr
2
15K
Member Avatar for Praveen_10

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 to fix growArray that also doesn't work. I will leave that for you to figure out.

Member Avatar for nullptr
0
205
Member Avatar for arifkhumaidi

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 imformation that matters to be salient. That doesn't just include alarms but information that leads up to an alarm, e.g. …

Member Avatar for Daemon_CC
0
174
Member Avatar for Learner010

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 your example: void afunction(int *x) { // Memory allocation BUT no deallocation x=new int; *x=12; } int main() { // …

Member Avatar for StuXYZ
0
151
Member Avatar for pinkamech

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. But I am going to point out some of the problems that are leading to segmentation faults/undefined behaviour, and things …

Member Avatar for pinkamech
0
5K
Member Avatar for ravi_14

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. CvPoint* PointArray=new PointArray[10]; // stuff PoinitArray=0; delete [] PointArray; (b) are you mixing C++ and C style memory allocations e.g. …

Member Avatar for rubberman
0
334
Member Avatar for nitish.mohiputlall

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(); std::cout<<"Enter number of modules:" ; std::cin>> x; for(row=0;row<x;row++) { std::cout << " Enter module code and marks :" <<(row+1)<<" "; …

Member Avatar for StuXYZ
0
151
Member Avatar for mc3330418

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 before cutting. If you put this in your code : `operand = (opCode.size()>12) ? opCode.substr(13,6) : "";` the code runs …

Member Avatar for mc3330418
0
300
Member Avatar for Jake_4

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 have done int t = n/freq; value[n] = amp*sin(2*pi*freq*t); n is an integer and freq is an integer, and using …

Member Avatar for StuXYZ
0
4K
Member Avatar for hamzabinamin

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 C++, the standard template library provides iterators to most container classes. In your instance you are providing a container class …

Member Avatar for StuXYZ
0
211
Member Avatar for Complete_1

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 guess what you are doing. So please post that file.

Member Avatar for Ancient Dragon
0
642
Member Avatar for michelemalta

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 the correct number. However, you use the variable guesses twice. This a scoping issue. First, there is the variable `guesses` …

Member Avatar for StuXYZ
0
390
Member Avatar for DS9596

You logic is flawed because you put == instead of >= . Consider the lines 15 -19 . while (num ==900) { cout <<"CM"; num = num - 900; } Now if number is 901, that isnt going to be executed, so you want to change the == to >= …

Member Avatar for StuXYZ
0
5K
Member Avatar for janith.amarawickrama

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) { id=A.id; name=A.id; } return A; } All works as I would expect. [Note you also have to add a declaration …

Member Avatar for rubberman
0
177
Member Avatar for thewalrus

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 important variabes are front/back. **Empty Case** Let us first conside the test case that you build an empty queue: `front=back=0`, …

Member Avatar for thewalrus
0
212
Member Avatar for Ese

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 program would break. After than finding the min positive value: That is a bit of a mess of logic/coding etc. …

Member Avatar for StuXYZ
0
145
Member Avatar for Yogesh_9

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]; You just can't do that in standard C++. The array is sized at compile time not runtime. [I know several …

Member Avatar for StuXYZ
1
376

The End.