Forum: C++ 1 Day Ago |
| Replies: 5 Views: 203 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++ 2 Days Ago |
| Replies: 5 Views: 203 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++ 2 Days Ago |
| Replies: 3 Views: 158 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++ 2 Days Ago |
| Replies: 3 Views: 162 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: Computer Science 3 Days Ago |
| Replies: 4 Views: 178 Ok, for maths courses have a look at the MIT lecture page http://ocw.mit.edu/OcwWeb/Mathematics/index.htm.
The undergraduate stuff is a great revision guide and most of it I would expect anyone in... |
Forum: C++ 3 Days Ago |
| Replies: 1 Views: 201 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: Computer Science 3 Days Ago |
| Replies: 4 Views: 178 This forum and others see this question a lot and you get answers that range from none - > everything.
So I will point out something that I have noticed, I have never studied and understood any... |
Forum: C++ 3 Days Ago |
| Replies: 4 Views: 131 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++ 3 Days Ago |
| Replies: 4 Views: 131 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++ 6 Days Ago |
| Replies: 4 Views: 249 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++ 6 Days Ago |
| Replies: 3 Views: 182 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++ 6 Days Ago |
| Replies: 4 Views: 247 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++ 6 Days Ago |
| Replies: 2 Views: 182 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++ 8 Days Ago |
| Replies: 2 Views: 196 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++ 11 Days Ago |
| Replies: 4 Views: 221 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++ 12 Days Ago |
| Replies: 4 Views: 145 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++ 12 Days Ago |
| Replies: 2 Views: 244 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++ 12 Days Ago |
| Replies: 12 Views: 340 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++ 12 Days Ago |
| Replies: 12 Views: 340 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++ 12 Days Ago |
| Replies: 12 Views: 340 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++ 20 Days Ago |
| Replies: 4 Views: 352 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++ 24 Days Ago |
| Replies: 4 Views: 201 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++ 24 Days Ago |
| Replies: 1 Views: 215 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++ 26 Days Ago |
| Replies: 11 Views: 260 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++ 26 Days Ago |
| Replies: 4 Views: 178 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++ 26 Days Ago |
| Replies: 11 Views: 260 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++ 26 Days Ago |
| Replies: 2 Views: 302 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++ 26 Days Ago |
| Replies: 11 Views: 260 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++ 31 Days Ago |
| Replies: 12 Views: 457 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++ 32 Days Ago |
| Replies: 10 Views: 296 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++ 32 Days Ago |
| Replies: 5 Views: 270 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++ 33 Days Ago |
| Replies: 5 Views: 270 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++ 34 Days Ago |
| Replies: 2 Views: 214 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++ 34 Days Ago |
| Replies: 2 Views: 175 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: 240 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: 168 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: 311 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 12th, 2009 |
| Replies: 4 Views: 195 Yes the problem is name reuse. The code compiles fine if you cahgne the name OR you put allocator in a namespace e.g
namespace X
{
template<class T>
class Allocator{
public:
... |
Forum: C++ Oct 12th, 2009 |
| Replies: 3 Views: 291 Well this looks like a c program (not a c++) so I will assume that you are in C and carry on.
The first question is that you have unfortunely added a \n after the %d in the scanf statement. That... |
Forum: C++ Oct 10th, 2009 |
| Replies: 4 Views: 654 Well ok then don't word the problem as if it is verbatim from the question sheet. Doesn't matter were you are tell us what you have got.
The problem can be broken down in to several parts (a)... |