Search Results

Showing results 1 to 40 of 54
Search took 0.01 seconds.
Search: Posts Made By: StuXYZ ; Forum: C++ and child forums
Forum: C++ 2 Days Ago
Replies: 3
Views: 112
Posted By StuXYZ
The trouble is that advance does not return an iterator, AND the iterator
(i in your code), has to be double derefrenced because the iterator points to a pointer and hence the error message. You...
Forum: C++ 16 Days Ago
Replies: 5
Views: 345
Posted By StuXYZ
I understand for quick solutions you would follow AncientDragon's sage advice.
However, that always leaves a sour taste since I am sure your want to know how to do it:

So here goes
...
Forum: C++ 17 Days Ago
Replies: 1
Views: 472
Posted By StuXYZ
This code is a mess, and 99% is that it is mixed c and c++ , it has not been set out tidily so neither I nor you know what is going on.

Things to fix:

Why use malloc to allocate memory use...
Forum: C++ 17 Days Ago
Replies: 4
Views: 217
Posted By StuXYZ
Indeed sfou, it is a method that is absolutely instinctive for most programmers. It is mainly mathematicians that have the big hang up with that sort of construct. They (and theoretical physists)...
Forum: C++ 20 Days Ago
Replies: 2
Views: 250
Posted By StuXYZ
As far as I understand the standard, this is not possible [I stand to be corrected].

There are slightly upsetting work-arounds.

First: If you don't need the virtual aspect, this is easy use a...
Forum: C++ 27 Days Ago
Replies: 2
Views: 317
Posted By StuXYZ
I think that you have got confused with the syntax of declaration and implementation. So here is an example with most of the common things you will likely need. [Please ask if I have missed...
Forum: C++ Oct 25th, 2009
Replies: 2
Views: 327
Posted By StuXYZ
The problem you have is temporary values and what happens to them:
I think this will be clear (I hope :)

The problem is that your are taking a copy of the value in the list. This does indeed...
Forum: C++ Oct 20th, 2009
Replies: 10
Views: 323
Posted By StuXYZ
First things first: Dont use system("Pause") it has been discussed to death here and everywhere on the web.

Second: The next problem is that you are using temp1 without initializing it. i.e every...
Forum: C++ Oct 15th, 2009
Replies: 6
Views: 324
Posted By StuXYZ
You seem to have two cin>>x in your code at lines 23 and 21. I would delete line 23.

I might make count and integer but that is minor.
you have remembered to initialize your variables which is...
Forum: C++ Oct 10th, 2009
Replies: 5
Views: 834
Posted By StuXYZ
Welcome to the real world. There is not free lunch.... sorry.
So
(a) either attend your classes and actually pay attention.
(b) decide that the class is not a good use of time and...
Forum: C++ Sep 20th, 2009
Replies: 5
Views: 266
Posted By StuXYZ
You have forgotten to use the return value of flip(). If you did this
if (flip()==1). I think you would be a lot better than looking at your loop count varible.

If really helps lots to run you...
Forum: C++ Aug 14th, 2009
Replies: 1
Views: 201
Posted By StuXYZ
A multitude of errors, mostly caused by trying to write everything in on go.

(a) Patient includes an instance to Doctor. Therefore you must have a declaration of Doctor before Patient is declared....
Forum: C++ Jun 28th, 2009
Replies: 7
Views: 423
Posted By StuXYZ
If you are writing a Pong game, I think that you are going to learn a lot, so well done.

Second AI in Pong is interesting, there are at least three models:

(a) pure deterministic. That is the...
Forum: C++ Jun 13th, 2009
Replies: 9
Views: 644
Posted By StuXYZ
If you don't want to post your code, then maybe a cut down version. But the quickest way to do it yourself is to compile with debug info on and then run and wait till it crashes. The backtrace will...
Forum: C++ Jun 3rd, 2009
Replies: 5
Views: 310
Posted By StuXYZ
while you are fixing this. Please note that you often write

for (int count=0;count<customer;count++);
{
// Stuff
}

Observe the semi colon after the for loop that should not be...
Forum: C++ May 8th, 2009
Replies: 10
Views: 1,044
Posted By StuXYZ
This thread is getting a bit messy. So I am going to write a quick summary and how I would tackle the problem.

First: Coordinates are almost never integers, and once you have solved a 2d problem...
Forum: C++ Apr 15th, 2009
Replies: 13
Views: 885
Posted By StuXYZ
Sorry, but most of these solutions are inelegant and that is because to achieve randomness they require an excessive number of random number calls:

(a) Shuffling the stack by selecting two cards...
Forum: C++ Mar 5th, 2009
Replies: 4
Views: 1,340
Posted By StuXYZ
You can't copy it to a set and back again without breaking the order.
Sets store on a compiler defined manor but normally red-black trees.
Hence you will destroy the order.

The easiest way is to...
Forum: C++ Mar 3rd, 2009
Replies: 14
Views: 997
Posted By StuXYZ
Below I am going to post a working set of code.

The requirements are simple. You write an implimentation of foo and you put template class Foo<float> in that implimentation.
This is 99% portable...
Forum: C++ Feb 11th, 2009
Replies: 5
Views: 712
Posted By StuXYZ
Please note that the code you have is 99% wrong.

Consider

Polynominal A;
A=A;


And before you say you would never do that, be very very careful of compiler opimization, double loops that...
Forum: C++ Feb 10th, 2009
Replies: 4
Views: 453
Posted By StuXYZ
That is no fun comatose!!!! The program should write itself without reference to the source code!!!

You want to look up quine

e.g.http://prokutfaq.byethost15.com/Cquine

I distinctly...
Forum: C++ Feb 3rd, 2009
Replies: 11
Solved: File I/O help
Views: 419
Posted By StuXYZ
errh... sorry Ancient Dragon, but the last line of the file is just "="?
Which was what I was trying to allude to.

The probelm seems to me to be that you read that with a statement...
Forum: C++ Jan 31st, 2009
Replies: 6
Views: 417
Posted By StuXYZ
Ok the usual rant: I hate system("PAUSE") and CLS. They are non-portable, and I can clear my own screen if that is what I want!

Beyond that you haven't given us much to go on.
You don't test if...
Forum: C++ Jan 31st, 2009
Replies: 5
Views: 431
Posted By StuXYZ
Returning to the problem asked:

The problem is that you have created a class that does nothing.
If you take the trouble to create a class don't ignore the values.
You can put tar=100000; and it...
Forum: C++ Jan 30th, 2009
Replies: 3
Views: 262
Posted By StuXYZ
Please be VERY CAREFUL with this code.

Consider

// THIS IS VERY VERY WRONG!!!!
char * getName(){
char buf[YOUR_ARRAY_SIZE];
sprintf(buf,name);
return &buf[0];
}
Forum: C++ Jan 29th, 2009
Replies: 4
Views: 502
Posted By StuXYZ
I think that the problem is not the code, but your maths.

Let us start with a number, e.g 89 as use used. What does writing 89 actually mean: that there are 8*10 + 9.

If you write in base 4 ,...
Forum: C++ Jan 27th, 2009
Replies: 1
C++
Views: 289
Posted By StuXYZ
Please do us all a favour and don't double post on multiple forums
E.g.

http://www.codeguru.com/forum/showthread.php?threadid=469551

You were shown short shrift there, because you code is...
Forum: C++ Jan 25th, 2009
Replies: 8
Views: 728
Posted By StuXYZ
I wish to comment again, since I now have understood what you are doing!!!! -- Well at least the problem, the code that is a different problem.

Let me see you want to get a position were the...
Forum: C++ Jan 22nd, 2009
Replies: 18
Views: 1,739
Posted By StuXYZ
I was the original person who suggested using a sieve of eratosthenes. Now does this still hold? I believe so and here is why.
You were required to find the factors. The only factors of importance...
Forum: C++ Jan 20th, 2009
Replies: 5
Views: 888
Posted By StuXYZ
This is a problem that requires thought NOT code.

The answer can be easily found on a piece of paper.

So without giving you the whole solution try thinking about this
Obviously 20!...
Forum: C++ Jan 19th, 2009
Replies: 6
Views: 300
Posted By StuXYZ
The obvious stuff is wrong : use of '\n' rather than std::endl. the complete lack of tests for input values.

e.g Would this be wrong

IntStack stack(-40);


so that is why you have a problem...
Forum: C++ Jan 15th, 2009
Replies: 8
Views: 367
Posted By StuXYZ
Before you get strangled with compiler errors. Please note that in c++
you write public: Then all things below are public (until either the end of the class or one of private: or
protected:
...
Forum: C++ Jan 6th, 2009
Replies: 2
Views: 396
Posted By StuXYZ
Let me see now your first post you were told that we don't help with assignments unless effort is shown.

THIS post you decide to ignore that reality and persist in asking please do my assignment...
Forum: C++ Jan 4th, 2009
Replies: 4
Views: 514
Posted By StuXYZ
The question should be asked "how do I delete a pointer if I allocate the memory using xxxx?"

Let us review:

if you write

double* Ptr=new double[50]; // Allocate space for 50 double s
//...
Forum: C++ Dec 19th, 2008
Replies: 2
Views: 337
Posted By StuXYZ
Looks like you are coping the pointer BUT not coping the array.
[This is often called weak-copy].
What happens is the memory for array1 is overwritten with something else and you have a copy of...
Forum: C++ Dec 19th, 2008
Replies: 10
Views: 718
Posted By StuXYZ
Well having been away (sorry). But I would like to make a summary of were I think we all are.

As is my custom, it will be with examples. Now the discussion is really about scope. In C++ it is...
Forum: C++ Dec 19th, 2008
Replies: 21
Views: 5,085
Posted By StuXYZ
The problem here is that g++ knows that only 64 bit can effectively be handled at the processor level. So the authors/steering committee have decided that if long int (which is 8 bytes long) is...
Forum: C++ Dec 10th, 2008
Replies: 4
Views: 371
Posted By StuXYZ
You haven't looked at the messages at the top of the forum.

You haven't looked at google.

You haven't actually done any reading.

You haven't read the forum rules.

Therefore:
Forum: C++ Dec 8th, 2008
Replies: 2
Views: 287
Posted By StuXYZ
Sorry but your errors include :
else {player = 'O' && num++;}

And that is equivilent to

player = ('O' && num);
num++;


That means that player == 1 or 0, and both of those are...
Forum: C++ Dec 8th, 2008
Replies: 10
Views: 1,674
Posted By StuXYZ
Given the HUGE size increase, if you have a calculation that can be done out to a large number, then the iterator route is best, (calculating the next on the fly). However, I haven't needed that by...
Showing results 1 to 40 of 54

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC