388 Posted Topics

Member Avatar for mitrious
Member Avatar for FrancisLazo

Before you learn about functions, I suggest you learn about how to write a loop and how to change the value of a variable.

Member Avatar for Red Goose
0
227
Member Avatar for Kelikmalok

You haven't posted all of your code, so it's hard to know what all your problems are. However, the code that you posted for charStack::push ahd charStack::pop is broken. To see this, try creating a charStack object, pushing a few characters onto it, and then popping them one at a …

Member Avatar for arkoenig
0
155
Member Avatar for TimBob12

I see nothing obviously wrong with the code you've shown. However: 1) You should be aware that writing a parameter of the form[icode]string foo[][/icode]means exactly the same as if you had written it as[icode]string *foo[/icode]-- that is, the parameter is just a pointer. 2) If you don't have a declaration …

Member Avatar for TimBob12
0
202
Member Avatar for gl7

On line 10 you say that you have a function named askGuess that takes no arguments and returns a char. On line 55 you define a function named askGuess that takes a string argument and returns a char. Because these functions have different argument types, the compiler assumes that they …

Member Avatar for gl7
0
148
Member Avatar for ntrncx

The problem is that there's a template in the standard library named plus, so your program is conflicting with that definition. Change the name to something else.

Member Avatar for ntrncx
0
109
Member Avatar for cwarn23

[QUOTE=invisal;1485461]There is no any square root algorithm that guarantee a 100% accurate result. For example: Let's say what is 100% accurate result of square root of 2? [/QUOTE] The IEEE floating-point specification requires the square root operation to return the representable number that is the correctly rounded value of the …

Member Avatar for mrnutty
0
843
Member Avatar for fpsasm
Member Avatar for sgw

I'm sorry to say that both answers are wrong. Example (a) uses the overloaded constructor that matches the argument, which in this case has type const char*. The string type is actually an instantiation of the basic_string template, so that string is equivalent to basic_string<char>; but putting that detail aside, …

Member Avatar for arkoenig
0
124
Member Avatar for bazza1984
Member Avatar for arkoenig
0
89
Member Avatar for maikens
Member Avatar for mrnutty
0
143
Member Avatar for Transcendent

There isn't a set of published answers for [I]Accelerated C++[/I] because Barbara's and my teaching experience is that if students have the answers already available, they don't try to solve the problems for themselves. Typically, if you don't know for sure whether your answer is right, it probably means you …

Member Avatar for arkoenig
0
1K
Member Avatar for purepecha
Member Avatar for arkoenig
-1
1K
Member Avatar for br007

if (sex=='m' || sex == 'M') { /* ... */ } Note the use of == rather than = and the use of ||.

Member Avatar for br007
0
122
Member Avatar for caut_baia

You haven't actually said what you want it to do, so it's hard to say whether it's ok. Copying a vector copies its elements. However, if those elements are pointers, copying a pointer doesn't copy the object that the pointer points to. This is true whether or not the pointer …

Member Avatar for caut_baia
0
3K
Member Avatar for iamthesgt

Don't use a for statement. The trouble with for statements is that they push you in the direction of iterating over a single range of values, and the problem you're trying to solve involves iterating over two ranges of values at once. What you want to do is have two …

Member Avatar for iamthesgt
0
364
Member Avatar for surferxo3

It's easy to arrange for numbers not to repeat in any row. It's also easy to arrange for numbers not to repeat in any column. However, at least at first thought, it is quite difficult to arrange for both conditions to hold at the same time, with the numbers still …

Member Avatar for surferxo3
0
145
Member Avatar for KazenoZ

When you say "Both lines work on their own if the other is removed from the code, and both functions used are not making any of the problems themselves," I am skeptical. Usually, if a program crashes when doing A and B, and it seems to work when doing A …

Member Avatar for KazenoZ
0
125
Member Avatar for jimJohnson

Memory-mapped IO is not part of standard C++, which means that your instructor must be expecting you to use some locally defined facilities for the purpose. Your first job is to find out what those facilities are. While you're doing that, I have three other suggestions: 1) Most of your …

Member Avatar for jimJohnson
0
224
Member Avatar for rogba

[URL="http://www.daniweb.com/forums/thread78223.html"]This[/URL] will tell you what to do.

Member Avatar for arkoenig
0
46
Member Avatar for biancaW
Member Avatar for eduard77

Read a file that contains text, in the form of words separated by whitespace (spaces, tabs, or newlines). 1) Print the longest and shortest words. 2) Print each word, together with how many times it occurs. 3) Print every word that occurs only once.

Member Avatar for eduard77
0
256
Member Avatar for joeyn

[CODE]for (int i = 0; i < 1; ++i) { for (int j = 0; j < 1; ++j) { cout<<"_ _ _ 1" << endl; cout<<"_ _ 2 2" << endl; cout<<"_ 3 3 3" << endl; cout<<"4 4 4 4" << endl; } } [/CODE]

Member Avatar for Akill10
0
126
Member Avatar for packluv12

In your program, nums is just a pointer to the first element of array1. If your assignment includes a requirement to allocate a new array, why not start by doing that and then figuring out what to do with it?

Member Avatar for jkoske
0
118
Member Avatar for ntrncx

There are 4 salespeople and 5 products. Let's number the salespeople 0 through 3 and the products 0 through 4. Then the problem is asking you to create a 4 by 5 array, where each row represents a different salesperson and each column represents a different product. So, for example, …

Member Avatar for VernonDozier
0
466
Member Avatar for lovely girl

Complexity is a word used to describe an attribute of the process by which you understand a C++ program. This process is called complex because it has a real part and an imaginary part.

Member Avatar for mrnutty
-3
105
Member Avatar for Mahesha999

Your array has 20 columns. When you use puts to read a string, it puts a null character ('\0') at the end of its input. So if your input is 19 characters or longer, the input (including the null character) runs off the end of the row of the array …

Member Avatar for arkoenig
0
276
Member Avatar for biancaW

The difference between [icode]int main()[/icode] and [icode]void main()[/icode] is that the first one is allowed in C++ and the second isn't. You're going to say "But my compiler accepts it!" And I'm going to reply "So? Compilers often accept code that's not valid. This fact doesn't make the code valid."

Member Avatar for vinayakgarg
0
151
Member Avatar for medopunsher

No; you don't need to implement BigNum. You can use someone else's implementation instead.

Member Avatar for arkoenig
0
109
Member Avatar for biancaW

The last time you asked for someone else to do your homework for you, I directed your attention [URL="http://www.daniweb.com/forums/thread78223.html"]here[/URL]. I do not think you actually read it, because if you did, you would not be asking again for someone to do your homework for you. So please, do us all …

Member Avatar for arkoenig
-3
101
Member Avatar for fpsasm

The declaration [code] Complex c[a]; [/code] isn't valid C++, though some compilers will accept it. Those that do will presumably take it to mean a request to define an array with "a" elements. Those elements will have indices ranging from 0 through a-1. When you subsequently execute [code] c[a].setComplex(temp1, temp2); …

Member Avatar for fpsasm
0
114
Member Avatar for blee93
Member Avatar for kra9853

@jkoske: You know what the question is. It's "I've done a little bit of my homework; will you do the rest for me?" The answer is (or should be) no.

Member Avatar for kra9853
0
584
Member Avatar for XA04
Member Avatar for Progr4mmer

You never change the value of your variable "current," so your program can never terminate.

Member Avatar for Progr4mmer
0
200
Member Avatar for eduard77

If by "best" you mean the closest to 12 without being greater than 12, then what you have just described is a version of the [URL="http://en.wikipedia.org/wiki/Knapsack_problem"]knapsack problem[/URL], which is known to be hard to solve efficiently.

Member Avatar for eduard77
0
251
Member Avatar for Kanoisa

Since when is 4 prime? Isn't that what you're claiming in line 20 of your code? Also, if you care about execution time, one easy way to speed things up is to observe that you don't have to divide a candidate by every prime; just by the ones that are …

Member Avatar for Kanoisa
0
288
Member Avatar for negneg

Use code tags. Without them, all your indentation goes away, which makes your code very hard to read. If your book really contained the line delete [] x,a,b,c,beta,gamma,r; then I suggest you stop using that book, because the author doesn't know C++ very well. Ditto for the overall design of …

Member Avatar for negneg
0
203
Member Avatar for aguilaron

It looks to me like you have an extra "if" and an extra pair of { } in line 30. That is, lines 29-30 should read else if (discriminant==0)

Member Avatar for Narue
0
1K
Member Avatar for EneilShade

Your statement int Size = sizeof Array / sizeof Array[0]; will not work if Array is a formal parameter, because in that case, Array is simply a pointer and sizeof Array is the size of a pointer. If you want to use an array parameter to represent an array, you …

Member Avatar for EneilShade
0
223
Member Avatar for jkoske

Who knows? You certainly have not pasted all the relevant code, because you haven't told us what the value of the variable "i" is or what the noBucket function does. I will say that your use of "i" makes me suspicious, because it's not a variable in your class. By …

Member Avatar for jkoske
0
216
Member Avatar for eduard77

If you are going to use the accumulate function to add floating-point numbers together, the third argument has to be 0.0, not 0

Member Avatar for eduard77
0
112
Member Avatar for Armistice

If you know how to do most of it, how about doing the part you know how to do, posting the code, and asking for advice on how to do the rest?

Member Avatar for Armistice
0
354
Member Avatar for lochnessmonster

I'm going to turn the question around: You can have a pointer to int, or a pointer to double, or a pointer to a class object, or a pointer to a function, or a pointer to an object of any of a bunch of other types I've left out. What …

Member Avatar for Ancient Dragon
0
96
Member Avatar for ERadu

[QUOTE=PMorphy;1465111]It's probably better to read and write the entire object. f.read( ( char* )aClassObject, sizeof( aClass ) ); f.write( ( char* )aClassObject, sizeof( aClass ) ); [/QUOTE] Don't even think about it. This technique will not work if the object in question contains any members of type string, or vector, …

Member Avatar for arkoenig
0
292
Member Avatar for KazenoZ

When you call getTile, you get a newly created value of type Tile. Your statement project._p->it->getTile(x, y).CPosX = panel2->Location.X;project._p->it->getTile(x, y).CPosX = panel2->Location.X; calls getTile to obtain such an object, then changes the CPosX member of that object, and finally throws the object away. Fortunately, C++ doesn't let you do that; …

Member Avatar for KazenoZ
0
581
Member Avatar for AnonymousX
Member Avatar for Prasanna Venkat

You have not specified the problem fully enough to make it possible to think about how to solve it. For example, first you say that the program should randomly generate 25 numbers, and then you say that "almost 15 or 16 numbers" (whatever that means) should be zero. It is …

Member Avatar for pseudorandom21
0
186
Member Avatar for cml352
Member Avatar for Mayank23

You can also define a map<string,int> that you can use to look up a string, obtain a corresponding integer, and use that integer in a switch. Depending on how you write your code, that strategy may well run faster, and be easier to maintain, than using a series of if-then-else …

Member Avatar for Fbody
0
261

The End.