Search Results

Showing results 1 to 40 of 388
Search took 0.03 seconds.
Search: Posts Made By: StuXYZ ; Forum: C++ and child forums
Forum: C++ 18 Days Ago
Replies: 4
Views: 404
Posted By StuXYZ
Do note: that for years before 1582, leap years where EVERY 4 years.
There was no 400 or 100 year rule. Prior to 325 the system was
1582 is a mess. Since they did not have a 5-14th October...
Forum: C++ 18 Days Ago
Replies: 3
Views: 206
Posted By StuXYZ
Ok the ugly cin.ignore is simply unnecessary. I have no idea why you might need it, it ignores the next 10 characters of input (say 10 random letters upto a return. Very strange. The std::endl...
Forum: C++ 18 Days Ago
Replies: 3
Views: 221
Posted By StuXYZ
Several problems are apparent.
(a) Turn is not initialized so will definitely be wrong
(b) loop variable j run 0 to 3 inclusive (j<4). so you access undefined memory locations in rot.
(c) rot is...
Forum: C++ 19 Days Ago
Replies: 3
Views: 237
Posted By StuXYZ
The problem you have is that your are using bare pointers. If you were using boost::shared_ptr or even std::auto_ptr then no problem.

So how to delete. You need to do TWO things: (a) delete the...
Forum: C++ 20 Days Ago
Replies: 3
Views: 237
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++ 34 Days Ago
Replies: 5
Views: 416
Posted By StuXYZ
Just a quick comment (again). The problem I though was not using printf. Yes I know that is not very C++ but if you need exact formated output, you normally end up at the boost::format class. That...
Forum: C++ 34 Days Ago
Replies: 5
Views: 416
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++ Nov 19th, 2009
Replies: 3
Views: 417
Posted By StuXYZ
Well I have written a system for extracting maths equations from input text which I currently use in several projects. So I just want to ensure you know what you are getting into it is about 2500...
Forum: C++ Nov 19th, 2009
Replies: 3
Views: 303
Posted By StuXYZ
I am sorry I don't like jonsca's solution, it has ugly temporary variables, that aren't necessary.

The better way to do this (IMHO) is to add two operators. One is operator<< and the other is...
Forum: C++ Nov 18th, 2009
Replies: 1
Views: 640
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++ Nov 18th, 2009
Replies: 4
Views: 258
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++ Nov 18th, 2009
Replies: 4
Views: 258
Posted By StuXYZ
Sorry but the main problem is that you have over complicated the if structure in FindFirst.

Several points

(i) You pass the value first BUT don't actually use it.
Let me elaborate. You use a...
Forum: C++ Nov 15th, 2009
Replies: 4
Views: 428
Posted By StuXYZ
Ok you have a number of problems:
So let me (a) post some working code: (b) tell you what each line does:

int main()
{
std::fstream bfile("file.bin",
...
Forum: C++ Nov 15th, 2009
Replies: 3
Views: 362
Posted By StuXYZ
Ok the original post was about gcc, which has a tolower function that
does not return a char, it returns an int and takes an int. That is because it works with internationalized character sets. So...
Forum: C++ Nov 15th, 2009
Replies: 4
Views: 473
Posted By StuXYZ
If you do write your own Gauss-Jorden elimination procedure, be very careful to deal with the huge numerical rounding errors. Re- stabalization of matrix after most steps is essential. Also please...
Forum: C++ Nov 15th, 2009
Replies: 2
Views: 287
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++ Nov 13th, 2009
Replies: 2
Views: 344
Posted By StuXYZ
Ok I am not going to deal with all of this mess but point out some of the basic errors and then ask how did you manage to get to this point.

-- Talk your first effort,

double
Individual::...
Forum: C++ Nov 9th, 2009
Replies: 4
Views: 377
Posted By StuXYZ
First thing that comes to mind is that a[9] and c[9] are not initialized.

Next you are using variables columns and row. So check that this->rows == u.columns. Then set the data in this. as c[]...
Forum: C++ Nov 8th, 2009
Replies: 4
Views: 187
Posted By StuXYZ
First off, you cannot write fractions fractions :: operator/(fractions f); within the definition of a class.

Second, you have provided a default constructor that set the fraction to 0/1 . That...
Forum: C++ Nov 8th, 2009
Replies: 2
Views: 367
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++ Nov 8th, 2009
Replies: 12
Views: 471
Posted By StuXYZ
I agree with Jonsa's point you can put [icode]using std::cout; [/CODE] etc, although it is important to remember that they can be put within a scope, e.g. in a function and not the global scope.
...
Forum: C++ Nov 8th, 2009
Replies: 12
Views: 471
Posted By StuXYZ
Well DONT use using namespace std;
You can write it like this:

std::ofstream File("Output.txt")
File<<"This is to the file"<<std::endl;
std::cout<<"Written line to the output file"<<std::endl;...
Forum: C++ Nov 8th, 2009
Replies: 12
Views: 471
Posted By StuXYZ
First: USE CODE TAGS

Second: you don't not have to declare the variable name in definitions e.g. void resultsfn(int& A); is the same as
void resultsfn(int&);.
This often makes code clearer
...
Forum: C++ Nov 1st, 2009
Replies: 4
Views: 392
Posted By StuXYZ
The bovious thing to do is to run it in the debugger e.g. gdb or ddd
Compile with g++ -g -o Prog prog.cpp, and the run as ddd Prog. When it hits the seg-fault, use up until you see the problem...
Forum: C++ Oct 27th, 2009
Replies: 4
Views: 240
Posted By StuXYZ
Well you don't seem to have written a operator>> for class ballTeam. I could be wrong since you didn't include the definition files (.h files).



I
Forum: C++ Oct 27th, 2009
Replies: 1
Views: 293
Posted By StuXYZ
I am not going to deal with all the things that are wrong here

They include:

(a) a missing = in a test else if (opr1 ='(')[/icode[
(b) stupid reassignment [icode]ifx[i] = ifx[i+1]; but loop...
Forum: C++ Oct 26th, 2009
Replies: 11
Views: 290
Posted By StuXYZ
Seriously, you are just going round in circles. You HAVE TO WRITE SOMETHING SIMPLER so that you get to grips with variables/ if else constructions / functions. And you are going to have to do it in...
Forum: C++ Oct 25th, 2009
Replies: 4
Views: 198
Posted By StuXYZ
This is code absolutely begging for a loop!!

Your actual problem is that you test x then y. That is incorrect. (I think)

Consider a box with coordinates (0,0) and (10,10). I.e it is a square of...
Forum: C++ Oct 25th, 2009
Replies: 11
Views: 290
Posted By StuXYZ
If you have a problem like that and don't understand the compiler error, then split the function into bit, e.g. calculate without the sqrt e.g.


double d=a+b;
distance=sqrt(d);


You have...
Forum: C++ Oct 25th, 2009
Replies: 2
Views: 350
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 25th, 2009
Replies: 11
Views: 290
Posted By StuXYZ
The first problem is that your are returning a string from a function that says it will return a floating point number..
e.g. points has returns "miss" But requires it to return a floating point...
Forum: C++ Oct 21st, 2009
Replies: 12
Views: 507
Posted By StuXYZ
If you are debugging code (and that is what you are doing here), you need to step through the code and check your assumptions. That can be done with a traditional debugger that lets you see each line...
Forum: C++ Oct 20th, 2009
Replies: 10
Views: 344
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 19th, 2009
Replies: 5
Views: 310
Posted By StuXYZ
Calling the destructor normally implies that the memory is listed as free, i.e. you can quickly find that the memory is corrupted with something else.

Try valgind to get a detailed picture of...
Forum: C++ Oct 19th, 2009
Replies: 5
Views: 310
Posted By StuXYZ
Let use be a little careful here about the sequence of events.
First off, if you examine the assembler/machine code that is 100% exactly what is going on. However, (a) that may mean that your...
Forum: C++ Oct 18th, 2009
Replies: 2
Views: 230
Posted By StuXYZ
firstPerson's answer works and solves the problem BUT for a large classes you might prefer to use explicit instantiation. [which gives the beginner a better idea of what is happening (sometimes)].
...
Forum: C++ Oct 17th, 2009
Replies: 2
Views: 189
Posted By StuXYZ
What about adding a class. Starting with that is a great way to group data together.

class UserInfo
{
private:
std::string Name;
std::string Pass; // THIS IS NOT SECURE
...
Forum: C++ Oct 17th, 2009
Replies: 3
Views: 287
Posted By StuXYZ
The reason (for good/bad) is that when the compiler hits instances.inc.
It has not seen the definition of graph.
If you put include instances at the end of graph.cpp all is fine.

Note that you...
Forum: C++ Oct 15th, 2009
Replies: 1
Views: 199
Posted By StuXYZ
It doesn't have an inbuilt function (but I am sure they are in libraries)
BUT surely it is this

int totalMin=890;
int min=total % 60 ;
int hour = (total / 60) % 24;
// etc


not exactly...
Forum: C++ Oct 15th, 2009
Replies: 6
Views: 349
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...
Showing results 1 to 40 of 388

 


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

©2003 - 2009 DaniWeb® LLC