Search Results

Showing results 1 to 40 of 372
Search took 0.02 seconds.
Search: Posts Made By: StuXYZ
Forum: C++ 7 Days Ago
Replies: 4
Views: 269
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++ 11 Days Ago
Replies: 4
Views: 165
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++ 11 Days Ago
Replies: 1
Views: 154
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++ 13 Days Ago
Replies: 11
Views: 227
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++ 13 Days Ago
Replies: 4
Views: 153
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++ 13 Days Ago
Replies: 11
Views: 227
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++ 13 Days Ago
Replies: 2
Views: 244
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++ 13 Days Ago
Replies: 11
Views: 227
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++ 18 Days Ago
Replies: 12
Views: 387
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++ 18 Days Ago
Replies: 10
Views: 279
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++ 19 Days Ago
Replies: 5
Views: 231
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++ 19 Days Ago
Replies: 5
Views: 231
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++ 21 Days Ago
Replies: 2
Views: 200
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++ 21 Days Ago
Replies: 2
Views: 170
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++ 21 Days Ago
Replies: 3
Views: 213
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++ 23 Days Ago
Replies: 1
Views: 149
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++ 23 Days Ago
Replies: 6
Views: 279
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++ 26 Days Ago
Replies: 4
Views: 182
Posted By StuXYZ
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++ 26 Days Ago
Replies: 3
Views: 255
Posted By StuXYZ
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++ 28 Days Ago
Replies: 4
Views: 533
Posted By StuXYZ
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)...
Forum: C++ 28 Days Ago
Replies: 5
Views: 480
Posted By StuXYZ
That doesn't sound useful idea. Consider this

(a) A polynomainal multiplication is a N * M process were the length of the polynominial are M and N.
(b) The polynominal can be sparse e.g. x^8+x. ...
Forum: C++ 28 Days Ago
Replies: 4
Views: 533
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++ 28 Days Ago
Replies: 4
Views: 180
Posted By StuXYZ
You could use some of the object orientation stuff , i.e. if all the variables in an object are private, then you can add a flag that they have been changed, when they are accessed via the...
Forum: C++ Oct 1st, 2009
Replies: 3
Views: 352
Posted By StuXYZ
Tough. Try telling that to the standard committee. Section 13.10 tells us that when an template is explicitly instantiated it is necessary to create ALL the methods. Additionally the compiler is no...
Forum: C++ Oct 1st, 2009
Replies: 11
Views: 404
Posted By StuXYZ
Sorry my fault about not being clear about point 1.

your code is

template <class E>
nodePtr<E> BinaryTree<E>::getNode(E item){
nodePtr<E> temp = new nodePtr;
temp->data = item;
return...
Forum: C++ Oct 1st, 2009
Replies: 3
Views: 352
Posted By StuXYZ
Basically your template instantiation is in the wrong piece of code.
It should be in the Temp.cpp.

Why: To create an instance of a class you have to have all the methods available to the...
Forum: C++ Sep 30th, 2009
Replies: 5
Views: 267
Posted By StuXYZ
It is that your decrement of y does absolutely nothing.

total start as???? Absolutely anything.

Your function is not recursive, it doesn't call itself. Imagen you call your function like this...
Forum: C++ Sep 30th, 2009
Replies: 5
Views: 267
Posted By StuXYZ
Your problem is the subtraction of y. It doesn't do anything.

The point about recussion is that in a default case you
return a value e.g. if (y==1) return x;
but in more general cases you...
Forum: C++ Sep 30th, 2009
Replies: 11
Views: 404
Posted By StuXYZ
(1) It is not pointless to use templates just that it is better to use references.
(2) However, designed the class didn't design it well enough to compile so it that is sufficient excuse then...
Forum: C++ Sep 30th, 2009
Replies: 11
Views: 404
Posted By StuXYZ
Ok first USE CODE TAGS. Sorry to shout but it is written in the introduction to the forum, it is written as the top announcement to this and almost every forum. e.g...
Forum: C++ Sep 29th, 2009
Replies: 3
Views: 286
Posted By StuXYZ
Just a quick note, since you look like you are going to get confused.
You really need to be working with double or floats, e.g.
3.4 or 34003.384 or 1.87561e2. Even if you input standard integers ...
Forum: C++ Sep 28th, 2009
Replies: 2
Views: 143
Posted By StuXYZ
I think you need either:

while(Choice!='n' && Choice!='N') { }

Note the && (and).

OR:
while(tolower(Choice)!='n') { }

Also please note you are very unlikely to need the ; after the while
Forum: C++ Sep 27th, 2009
Replies: 11
Views: 404
Posted By StuXYZ
First off, shurik_r got most of that correct, however, you cannot use
typedef for unspecified templates , so you cant write

// THIS IS NOT ALLOWED
template <class E>
typedef node<E>*...
Forum: C++ Sep 27th, 2009
Replies: 2
Views: 580
Posted By StuXYZ
The normal way to do this is to use a stringstream.
Now you have to be VERY VERY careful, with this.
The reason is that if you do

double Res;
std::string A="3.4e5x"
std::stringstream IX(A);...
Forum: C++ Sep 26th, 2009
Replies: 3
Views: 188
Posted By StuXYZ
You can compile everything as separate files BUT to get an executable you need to link all the files required.
e.g. in three command do this:

g++ -Wall -c Taddmain.cpp
g++ -Wall -c Tadd.cpp...
Forum: C++ Sep 26th, 2009
Replies: 3
Views: 284
Posted By StuXYZ
Ok there are many many thinks to really really dislike about this code.
In particular is the "cleverness".

Ok first, it is int main(). That has been said a million times on this forum.
...
Forum: C++ Sep 25th, 2009
Replies: 6
Views: 258
Posted By StuXYZ
The problem is that you have a map of type
map<string,list<pointer> >.

You are doing two thing wrong:

std::map<std::string,std::list<Operation *> >::iterator labelPtr;
labelPtr =...
Forum: C++ Sep 25th, 2009
Replies: 3
Views: 185
Posted By StuXYZ
well then the first thing to do is to find out if you get to your first system command. Put a std::cout<<"TEST"<<std::endl; exit(1) at line 17 of your main. Then see if you get that without a seg...
Forum: C++ Sep 25th, 2009
Replies: 4
Views: 501
Posted By StuXYZ
Actually, if you are doing a binary search, make 100% certain that you understand the algorithm in 1D. That is important since 2D array can be easily thougth of as a 1D array. The binary search can...
Forum: C++ Sep 25th, 2009
Replies: 4
Views: 501
Posted By StuXYZ
Note 100% certain I follow what you are trying to do.
But some points:

(a) C++ is almost space insensitive. The only areas you have to worry are in the middle of keywords e.g. cla ss A { } is...
Showing results 1 to 40 of 372

 


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

©2003 - 2009 DaniWeb® LLC