388 Posted Topics

Member Avatar for biancaW

Please read [URL="http://www.daniweb.com/forums/thread78223.html"]this[/URL].

Member Avatar for arkoenig
0
285
Member Avatar for stephy1

[URL="http://www.daniweb.com/forums/thread573.html"]Here you go.[/URL]

Member Avatar for masijade
0
54
Member Avatar for alex55

In the future, please post a complete program. However.... Even though this program is incomplete, I can see a serious problem: In C++, arrays start with an index of 0. So when you write a loop such as [CODE] for(int i=1; i<=month; i++) { monthAverage[i] = monthSum[i] / month; } …

Member Avatar for alex55
0
123
Member Avatar for daniel1977
Member Avatar for c++probeginner

You have defined acknowledge_call to take eight arguments. You have called it with no arguments. Hence the error message. Next time, please use code tags.

Member Avatar for arkoenig
0
157
Member Avatar for MasterGberry

Your dealCard member function has a serious flaw: It returns a reference to a local variable, which will refer to nothing valid after the function has returned. You should probably just return a Card (assuming that Card is a class whose values you can copy). If you're going to use …

Member Avatar for MasterGberry
0
190
Member Avatar for MasterGberry
Member Avatar for Zvjezdan23

Change "int i = 0" to "vector<string>::size_type i = 0" in line 44 and to "string::size_type i = 0" in lines 58, 71, and 84. Next time, please cite the text of the error message so we don't have to look it up.

Member Avatar for Zvjezdan23
0
183
Member Avatar for realproskater

In line 11 you say that gpa_Sorter takes two arguments: a double and an int. In line 31 you call gpa_Sorter with an array of double. Thus the error message.

Member Avatar for realproskater
0
247
Member Avatar for Mayank23

You first. Otherwise it looks too much like you're asking someone else to do your homework for you.

Member Avatar for alaa sam
0
109
Member Avatar for LevyDee

[QUOTE=LevyDee;1456560]I tried the second example there and I get the same runtime error. My runtime error is: Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)[/QUOTE] I'll bet you tried to execute [CODE]delete [] error;[/CODE] but because error isn't pointing to memory that was allocated with [ICODE]new[/ICODE], you mustn't delete it.

Member Avatar for nndung179
0
231
Member Avatar for MasterGberry

If you're using consecutive integers for the map indices, why not just use a vector? Independently of that, it would seem to me that you could simply replace lines 8 through 11 of your code by a call to std::swap(theDeck[i], theDeck[r]) and delete line 4 entirely.

Member Avatar for MasterGberry
0
1K
Member Avatar for pucivogel
Member Avatar for katniss

[URL="http://www.daniweb.com/forums/thread78223.html"]Here you go.[/URL]

Member Avatar for arkoenig
0
125
Member Avatar for pucivogel
Member Avatar for JordanHam

What have you tried so far? Why doesn't it work? What sort of trouble are you having?

Member Avatar for JordanHam
0
129
Member Avatar for Carrots
Member Avatar for XodoX
Member Avatar for Violet_82

I'll reinforce what PhysicsExpert said: I see no reason to define a class here. That said, I'd like to point out some other problems with your code. Perhaps the most important problem is that what your program actually does is different from what you said you were asked to do. …

Member Avatar for Violet_82
0
192
Member Avatar for sidra 100

Wouldn't you think that when someone posts a program in a C++ forum and asks for help, the program would actually be a C++ program?

Member Avatar for ravenous
-6
117
Member Avatar for jmaple

Yes, that's what it means. A reference to a pointer is useful for exactly the same reasons that a reference to any other type is useful.

Member Avatar for jmaple
0
99
Member Avatar for flasp
Member Avatar for MasterGberry

You can replace [code] for (unsigned long int k = 0; k < inTables[q].Items.at(j).Size; k++) inTables[q].Items.at(j).Data.push_back(tempItem[k]); [/code] with [code] inTables[q].Items.at(j).Data.insert(inTables[q].Items.at(j).Data.end(), tempItem, tempItem+inTables[q].Items.at(j).Size); [/code] with the same effect. However, it would not surprise me to learn that doing so does not change the speed of your program much. Unless you have …

Member Avatar for MasterGberry
0
152
Member Avatar for ankit,joy

Break it into manageable chunks. Sort each chunk into a file. Merge the files into another file.

Member Avatar for arkoenig
0
520
Member Avatar for elsiekins

You can't have an array of size 0, in the sense that every array type includes the number of elements as part of the type, and for the type to be well defined, the number of elements must be strictly positive. Part of the reason for this requirement is to …

Member Avatar for elsiekins
0
422
Member Avatar for MasterGberry

In line 1 of your code, you add an integer to what you claim is a vector. I don't know what you think that's supposed to do, but it's not well defined in standard C++. Four times in you code, you explicitly convert an enum to an int. That shouldn't …

Member Avatar for elsiekins
0
163
Member Avatar for eline83

Sounds like you need to measure the time more accurately. I suggest wrapping another loop around the entire program to run it a thousand times or so, and figuring out from that how long it takes to run once.

Member Avatar for eline83
0
120
Member Avatar for docmccoy

You've initialized myList to myList, creating a circular reference that then you cannot undo. I think you will make your life easier if you use a pointer instead of a reference.

Member Avatar for arkoenig
0
114
Member Avatar for XerX

What is the difference between decimal random numbers and other kinds? Putting it differently, exactly what are you trying to do?

Member Avatar for MosaicFuneral
0
3K
Member Avatar for TailsTheFox

[QUOTE=Narue;1445456][ICODE]if(test_command == true)[/ICODE] should be [ICODE]if(test_command() == true)[/ICODE].[/QUOTE] Yes. But there's another subtle point here that is worth mentioning. It is generally a bad idea to write expressions of the form [icode]function() == true[/icode]. It is harmless to do so if the function returns a bool value, as test_command does …

Member Avatar for arkoenig
0
115
Member Avatar for ivaylo91

[QUOTE=vijayan121;1438221]Since x, y are integers limited to the inteval [ -100, +100 ] there are just 200*200 == 40000 possible tuples (x,y). Just use brute force.[/QUOTE] 201 * 201 = 40401 possible tuples.

Member Avatar for ivaylo91
0
2K
Member Avatar for lulzy

[QUOTE=lulzy;1436726]But, in my case, the classes A, B and C don't contain values by which they could get sorted and that's the trick. [/QUOTE] Of course they do! That's the point of the value function Narue suggested. You override that function in each of your derived classes to return a …

Member Avatar for Red Goose
0
218
Member Avatar for MasterGberry

Maybe your compiler doesn't completely support C++0x initializations yet. What happens if you replace the curly braces with parentheses in the last line of code in your example, and change "auto" to "AoE2Wide::Item*" ?

Member Avatar for MasterGberry
0
573
Member Avatar for LevyDee

The variable "last" you use in line 7 isn't defined, nor is it given a value anywhere. If your list has only a single element, then presumably after you remove it, you need to set head to 0. Nowhere in the code is it possible for that to happen.

Member Avatar for LevyDee
0
110
Member Avatar for reemhatim

You've been studying this subject for two years. Surely you must be able to do [I]something[/I]. So how about showing us how much of your program you've written successfully. Then you might get a hint as to what to do next.

Member Avatar for reemhatim
0
200
Member Avatar for stevanity
Member Avatar for ricky_125

Yes. More seriously, if you're running this program on a 32-bit machine, you're probably asking for much more memory than the system is capable of providing; and it would not be surprising to learn that an overflow is taking place as part of computing how much memory you need.

Member Avatar for ricky_125
0
135
Member Avatar for saadahkh

This code has lots of small errors that I'm going to leave it to you to find. I'll just point out the big error. Lines 47-66 read all the contents of in2. When you're done, you've reached the end of in2. Now line 67 tests whether you've reached the end …

Member Avatar for WaltP
0
516
Member Avatar for by_stander

A somewhat easier way to write [CODE] copy(d1.begin(), d1.end(), d0); copy(d2.begin(),d2.end(), &d0[d1.size()]); copy(d3.begin(),d3.end(), &d0[d1.size()+d2.size()]); [/CODE] is as follows: [CODE] double* next = copy(d1.begin(), d1.end(), d0); next = copy(d2.begin(), d2.end(), next); next = copy(d3.begin(), d3.end(), next); [/CODE] After this code, next points to the first available location in d0.

Member Avatar for by_stander
0
2K
Member Avatar for cute cat

The recursive call to CheckSmaller (with the comment) will never be executed because either path of the if statement before it will return first. So I don't even need to read the rest of the code to see that it's wrong.

Member Avatar for Red Goose
0
202
Member Avatar for indr

What do you think happens when you execute the following? [CODE] { link_list x; x.insert(42); link_list y = x; } [/CODE]

Member Avatar for indr
0
224
Member Avatar for Jelte12345

There is no way to determine where in a file each line begins without reading the entire file (unless you're creating the file, in which case you can remember the line locations as you write them--but that's the same kind of operation as reading it). So I don't see any …

Member Avatar for arkoenig
0
562
Member Avatar for gilly231

It's hard to believe that this is your actual code, because you don't declare a return type for any of your print functions. I see no reason why calling print on a pointer to a C object should call anything but C::print, so I can only conclude that your problem …

Member Avatar for gilly231
0
195
Member Avatar for vanalex

Two points: 1) Why do you think your code was executed correctly? Is it not possible that it just happened to appear to be correct by coincidence? How would you go about proving that it was executed correctly even without a copy constructor. 2) If you have a copy constructor, …

Member Avatar for vanalex
0
152
Member Avatar for Diogo Martinho

You can't do it directly, and it's hard to understand why you would want to so--because if you could, the [I]behavior[/I] of your program would depend on the names you choose for its components.

Member Avatar for arkoenig
0
81
Member Avatar for AnonymousX

Well, yeah. Line 7 defines situation as a reference to an object of type BattleSituation that you have promised not to change (because you defined it as a reference to const). Line 9 calls the getHPData member of situation. That member is permitted to change the value of its object …

Member Avatar for arkoenig
0
246
Member Avatar for erogol

Why don't you start by describing your ideas? Then other people will be more likely to contribute theirs.

Member Avatar for MosaicFuneral
0
131
Member Avatar for tomtetlaw

Shouldn't line 75 be assigning to data[size], not data[size-1]? Also, what does Q_memcpy do? That's anot a standard function, and you don't include its definition.

Member Avatar for arkoenig
0
143
Member Avatar for seanbp

Step 1. Understand the problem thoroughly. Step 2. Realize that I was really serious about step 1, and go back and understand the problem even more thoroughly. Step 3. Write the clearest, most straightforward program you can that solves the problem correctly. Step 4. Measure your program's performance. If you're …

Member Avatar for vijayan121
0
107
Member Avatar for narlapavan

There are no 2D vector types in standard C++. There are only vectors of vectors (or vectors of maps, or whatever).

Member Avatar for Ancient Dragon
0
147

The End.