1,358 Posted Topics

Member Avatar for skorm909

A common one is [ICODE]cin.get()[/ICODE]. It will work as long as you have a "clean" input stream.

Member Avatar for vsvivek796
0
229
Member Avatar for Tiancailee

This is your problem right here. There are a lot of problems with it:[CODE] void setRate(float r) { rate = r; }; int getRate(void) { return setRate(); }[/CODE] [list=1] [*]Inside getRate(), you are attempting to return the value returned by setRate(), which has no return value because it's specified as …

Member Avatar for Tiancailee
0
176
Member Avatar for ace8957

The [B]"arrow" operator[/B] is used with pointers to objects to access an object's members [B]via the pointer[/B]. From what I can tell though, your variable "hp" is not a pointer, it's an actual object. Try replacing the "arrow" operator with the "dot" operator: i.e. [iCODE]hp = hp.next;[/iCODE]. The [B]"dot"[/B] operator …

Member Avatar for ace8957
0
269
Member Avatar for jontes

None of your sample classes have semi-colons after their definitions. Is this an error in your example or does it appear in your code as well? Without those closing semi-colons, the compiler will get VERY confused.[CODE] class SampleClass { // member declarations }; //<---required semi-colon[/CODE]

Member Avatar for jontes
0
4K
Member Avatar for morewater14

I'm not trying to be harsh, but this needs a lot of work. Line 12 is not legal C++ syntax. If you want an array of variable size, you need to use a pointer, dynamic memory management functions (operator new[] and operator delete[]), a proper destructor, and variables to track …

Member Avatar for Fbody
0
183
Member Avatar for Tiancailee

@OP (on-topic): Class inheritance is based on a "base" or "general" cases/classes and "derived" or "specialized" cases/classes. The properties of the base class are designed in such a way that it applies to all objects of that class. Conversely, the derived classes are designed in such a way as to …

Member Avatar for Fbody
0
188
Member Avatar for skorm909

What sort of behavior are you getting? What does the code that's before it do? Your solution to this situation lies in those details. Unfortunately, we don't have them so all that we can do is speculate at best.

Member Avatar for skorm909
0
3K
Member Avatar for glamourhits

Go back to your chapter on functions, then answer these questions: How do you write the definition of a function? The header is the first line of the definition.[CODE] int myFunc(type myParam) { //function header /* ... function body ... */ return someReturn //return statement } //end of function[/CODE] How …

Member Avatar for alaa sam
0
85
Member Avatar for Firo

The problem is that you're combining different types of inputs. getline() reads up to, [B]extracts and discards[/B], the newline character that exists at the end of a line of input. The extraction operator (>>) reads up to, [B]and leaves[/B], the newline character at the end of a line of input …

Member Avatar for Fbody
0
177
Member Avatar for acv528k

You should change this to a "priming read" arrangement:[CODE] int someNum = 0; //declare and initialize input variable cout << "Please enter a non-zero value: "; //priming prompt cin >> someNum; //priming read while (someNum != 0) { //begin while loop for (int i = 0; i < 20; ++i) …

Member Avatar for Fbody
0
131
Member Avatar for kyuu

Can you be more specific about the information in the error? I think the problem is with your definition of the EMove enum. The members of an enum are all integer constants, not chars. This means that keUp is not literally the char 'w', it's the integer 119, 's' is …

Member Avatar for Fbody
0
168
Member Avatar for Philosophy

I have a feeling your conversion process is what [URL="http://www.daniweb.com/forums/thread329755.html"]your other thread[/URL] is about. Take the result of the equation I suggested in [URL="http://www.daniweb.com/forums/post1407872.html#post1407872"]this post[/URL] and combine it with an output manipulator to produce a continuous string of padded "numeric" characters. Then, when reading the file, use a character-based input …

Member Avatar for Philosophy
0
279
Member Avatar for Jason Giggs

[URL="http://en.wikipedia.org/wiki/Farkle"]Make a Farkle game[/URL]. I did a console-based version of it, these are the classes I used: [list][*]Die [*]DieSet [*]FarkleGame [*]GameConfig [*]Player [*]PlayerSet[/list] I also had a bit field called "ruleFlags", but don't worry about that unless you really want to. While working on it, I found out that they …

Member Avatar for Fbody
0
113
Member Avatar for Philosophy

If you detect the "case" (upper/lower), then use mathematics, you should be able to save a ton of code. I think you may want to consider something like this:[CODE] if (islower(input)) { //detect a "lower" case character value = 10 + (input - 'a'); //perform the translation } else if …

Member Avatar for Philosophy
0
436
Member Avatar for fubuaddict

Well, I'm having some trouble reading your code because you didn't use code tags. What I can tell you though is that this: `if ((X == 'V') || (X == 'I') || (X == 'R') || (X == 'U') || (X == 'S'))` is not correct. This will cause your …

Member Avatar for Fbody
0
80
Member Avatar for brycematheson

Do you know how to traverse a single-dimensional array?[CODE] const int SIZE = 6; //declare a constant for the array size int myArray[SIZE] = {0}; //declare and initialize the array for (int i = 0; i < SIZE; ++i) { //traverse an array/row myArray[i] = i; }[/CODE] You can use …

Member Avatar for Fbody
0
132
Member Avatar for Tiancailee

Hmmm... Perhaps answer this question: Which part(s) of this code are you responsible for? Are you expected to make your code fit with the provided code? Which section(s) of the code are provided?

Member Avatar for Tiancailee
0
135
Member Avatar for kdcorp87

I think you may want to describe the program's use case a little better and provide the relevant code. I don't know OpenGL, I don't do anything with graphics just yet, but it sounds like it's probably a dirty input stream. Console applications tend to behave similarly to that if …

Member Avatar for Fbody
0
407
Member Avatar for Meat!

[url]http://www.cplusplus.com/[/url] There are all sorts of references and a decent tutorial there. Oh, and don't expect to learn it all in one day...

Member Avatar for chiwawa10
0
87
Member Avatar for bookmark

You have arguments to your 3 functions but you haven't declared or initialized them before using them. Additionally, your function prototypes don't match your functions' definitions. I think I see what you are trying to do, but you haven't implemented it correctly. This is what you need to do to …

Member Avatar for Narue
0
277
Member Avatar for digan

Fill this in:[CODE] class Queue { //what goes here? };[/CODE] Then, instantiate it in your main() and manipulate it accordingly.

Member Avatar for digan
0
97
Member Avatar for Dmiller071

[QUOTE][CODE]void Enemy::Attack([B]Player a[/B], Enemy b){[/CODE][/QUOTE] Yes, it's a scoping issue. You're passing a [B]copy[/B] of a Player. You should be passing either a [B]pointer[/B] or a [B]reference[/B] to the Player.

Member Avatar for Dmiller071
0
194
Member Avatar for gpjacks

[B]>>Please only respond if you actually want to help. Not to name names, but some people on here are just rude.[/B] Speaking of rude... Good luck with your assignment.

Member Avatar for Fbody
-2
111
Member Avatar for jsav

You have a large amount of numeric input in this program. When you use the "extraction operator" ( >> ) for numeric input, it leaves a lingering "newline" character on/in the input stream, making the stream "dirty". To remove this lingering character, place a [iCODE]cin.ignore()[/iCODE] immediately after each numeric input …

Member Avatar for Fbody
0
858
Member Avatar for kuromiyaruka

I don't think they're just jumbling it. I think that, for whatever reason, they're trying to re-order the data diagonally from top-right to bottom-left rather than horizontally. You are correct though. [URL="http://www.daniweb.com/forums/announcement8-2.html"]We need to see some effort first.[/URL]

Member Avatar for daviddoria
-1
68
Member Avatar for Transcendent

[QUOTE=Transcendent;1404773]it did work man. can you write it.[/QUOTE] [URL="http://www,daniweb.com/forums/announcement8-2.html"]Are you joking?[/URL] It's 2 extremely simple changes. Change num to i inside the loop then add another output line. It's not that hard.

Member Avatar for Shankye
0
167
Member Avatar for mzetka3

Doesn't really surprise me, an error like that usually implies a missing function implementation. Glad you figured out what was missing.

Member Avatar for Fbody
0
90
Member Avatar for bookmark

I don't see any tests to verify that the files have been opened successfully. Do you know that the output file is actually being opened properly? Example:[CODE] #include <iostream> #include <fstream> using std::cout; using std::ofstream; int main() { ofstream outFile("filename.txt", std::ios::out | std::ios::trunc); //declare the output file stream if (outFile.is_open()) …

Member Avatar for Fbody
0
210
Member Avatar for Rorkhill

Well, it's a little tough to help much due to a lack of context. I think it would be helpful if you posted a little bit more code so that we can see your overall context better. Generally though, if you need a section of code to repeat you'd use …

Member Avatar for Fbody
0
982
Member Avatar for knellgust

The new[] operator doesn't work like other operators. To use it, you must have a pointer that you are storing the return value to.[CODE] dataType *pDataType = 0; //declare a NULL pointer to a dataType pDataType = new dataType[arraySize]; //create an array on the heap, store it's address in the …

Member Avatar for Fbody
0
80
Member Avatar for DynamicMember

getch() is part of the conio.h header, which you haven't included. That's actually a good thing, it really should never be used, it is not a standardized header. Instead, put a cin.get() directly before your return 0; (Line 46).

Member Avatar for profyou
1
112
Member Avatar for aznlitomik3

The first question you need to answer is "How do I add a fraction?". Once you answer that, you know what you need to do in plusEquals. Take that same basic question and apply it to the other methods. [B]>>The problem require to ask the user for the fractions[/B] Yes …

Member Avatar for aznlitomik3
0
1K
Member Avatar for Fbody

I'm really intrigued by OOP, I feel that I can help most people with OOP questions reasonably well, but I still have a lot to learn and there's something that bothers me. What is the best way to write the program's main() if I want to create a truly OOP …

Member Avatar for Fbody
0
161
Member Avatar for Cragsterboy

Why are you dropping into assembly? Why not just use the C++ arithmetic operators and loop statements?

Member Avatar for Cragsterboy
0
100
Member Avatar for Blenor

Care to elaborate on the errors? We're not mind-readers. Looks like you need to pay closer attention to your variable names. I can see several instances of variable names not matching. On Line 9, you declare a double called "dfistnumber". It seems you want to input to it on Line …

Member Avatar for alaa sam
0
146
Member Avatar for dinners

[QUOTE][CODE]bool isSame=false; do { bool isSame=false; for (int i=1; i<=corners; i++) //... }while (isSame==true);[/CODE][/QUOTE] This section of code is a big no-no. The "isSame" on Line 1 is not the same "isSame" as the one on Line 4. Your do-while loop defines a program scope that is separate from the …

Member Avatar for dinners
0
302
Member Avatar for shotbylammi

Dev C++ is crap. Don't use it unless you have to. Use Code::Blocks or VC++ Express instead. I wouldn't use a "Windows Application". I would suggest a "Console Application". Then, you create a *.cpp file and put your code in the *.cpp file. EDIT: Oops, AD beat me to it.

Member Avatar for Fbody
0
171
Member Avatar for NichtSoGut

std::bad_alloc is what is known as an "exception". To use exceptions, you need to use a try ... catch block. If an error is encountered, you "throw" (not return) an exception. The exception is then caught by the appropriate catch block. Some functions, such as new, automatically throw them for …

Member Avatar for StuXYZ
0
482
Member Avatar for knellgust

[QUOTE][CODE]double getPrice() const; //<----- naughty semi-colon use {return price;}[/CODE][/QUOTE] Lose the semi-colon after the const. You do not place a semi-colon after the header line of a function's definition. That turns it into a function prototype and then you're left with a dangling statement block that's not recognized as the …

Member Avatar for SgtMe
0
172
Member Avatar for Mr_PoP

[QUOTE=Mr_PoP;1402083]dude it's just for jokin with my real friends i dont use my knowledge to piss the people off , besides i just wanna know why it does not work on XP :)[/QUOTE] Regardless, this can be construed to fall under the "Keep it Legal" section of the [URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]Member Rules[/URL], …

Member Avatar for peter_budo
-2
166
Member Avatar for nickx522

Find the min/max as you normally would, then store the indexes of the low/high values, in addition to the values themselves. You would then modify your output stream based on the current index rather than the actual value. If your current index for your output matches either stored index, you …

Member Avatar for nickx522
0
107
Member Avatar for tallyhop

For starters, you need to move your struct definition out of your main(). Put it after your using statement. Your recordCount should be separate from your struct, it should not be part it. After you verify that you have successfully opened your file, you should do an initial read to …

Member Avatar for tallyhop
0
464
Member Avatar for gpjacks

You have 2 problems: First, you have the same problem as in [URL="http://www.daniweb.com/forums/thread326696.html"]your previous thread[/URL]. Unless you're some sort of prodigy, you can't just barf something into your code and expect it to work correctly. You need to start taking the time to think about how you write your output …

Member Avatar for Fbody
0
126
Member Avatar for Ninjah

[QUOTE=Ninjah;1401823]I don`t uderstand how it is possible because I`ve tried to open a file as follows: ifstream infile("C:\Users\NINJAH\Documents\Visual Studio 2008\Projects\myfile.txt"); but it does not work. The thing is that I`ve tried to put double \ characters and it worked..no errors it reads from the file. And when I use the …

Member Avatar for Fbody
0
5K
Member Avatar for alainigban

[QUOTE=alainigban;1401842]I'm sorry for posting the whole code here, i think the problem is not really on line 121. gerard4143 i've tried your suggestion, b[/QUOTE] It's not, it's on line 58, like Gerard said. It's flagging 121 because your error around Line 58 closes the if's scope prematurely thus preventing it …

Member Avatar for Fbody
0
249
Member Avatar for SVSU_Student

Wasn't this same issue already discussed in [URL="http://www.daniweb.com/forums/thread325697.html"]your introductory thread[/URL]? Not only are you double-reading, which will mess you up really bad, you are using a for loop. It is better to use a while loop instead of a for loop to read your file, it's much easier, and less …

Member Avatar for Fbody
0
166
Member Avatar for minskypooh

I suggest you hand-trace your program's execution. I see a couple things: [LIST=1][*]Your class does not have a constructor. it's relying on the compiler-provided default which does not appear to be sufficient for this class. [*]Because you don't have any constructors, your Student member values are not being initialized properly. …

Member Avatar for minskypooh
0
199
Member Avatar for Abayiz

What exactly do you mean by "it generates only one column"? Can you provide a sample output? [URL="http://www.daniweb.com/forums/announcement8-3.html"]Also, some example source code would be beneficial.[/URL]

Member Avatar for Abayiz
0
170
Member Avatar for gpjacks

[B]>>#1). Write a loop that will print the values in a 20 element vector named quantity to the screen. (When I compile the code it increments by 10 for the 20 values and I'm pretty sure this isn't correct)[/B] It's not actually incrementing by 10, it just looks like it …

Member Avatar for gpjacks
0
266
Member Avatar for vanalex

Let's just say you're lucky it worked. Technically, what you have written is [B]accurate syntax[/B], but it is [B]logically incorrect and very dangerous[/B] code. Because it's simply a pointer to a single char, there is not sufficient memory allocated where that char is stored to hold an array of char. …

Member Avatar for WaltP
0
67

The End.