1,358 Posted Topics
Re: All you have to do is enter them just like you see them. Just be mindful of your parentheses. For the series situation, you'll probably want to use a loop of some sort and just total up the user's input values. EDIT: You're kidding me, this thread sat for an … | |
Re: Please figure out your [URL="http://www.daniweb.com/forums/announcement8-3.html"][B][COLOR="red"][noparse][CODE]...code tags...[/CODE][/noparse][/COLOR][/B][/URL], then maybe we can help. [CODE] #include <iostream> int main() { std::cout << "This looks nice, and is easily readable." << std::endl; return 0; }[/CODE] #include <iostream> int main() { std::cout << "This looks like dung, and isn't readable." << std::endl; return 0; } … | |
Re: All of your variables are declared as floats. Check your data types. Not every piece of data in a program is a floating-point number... You may also want to look at how you are using GrossPay.[QUOTE][CODE]FedTax = GrossPay * 0.20; StTax = GrossPay * 0.05; GrossPay = RegularPay + OvertimePay; … | |
Re: I suspect this is a variation on [URL="http://www.daniweb.com/forums/thread312661.html"]your previous question[/URL]. This variant has the same issue as your previous one. If you are going to use a multi-word command, you need to use string manipulation functions to normalize it then break it up and analyze the individual parts of the … | |
Re: Speaking in terms of Logic, there are 2 basic loop types; the [B]determinate[/B] loop and the [B]indeterminate[/B] loop. A [B]determinate[/B] loop is a loop that must run X number of times. For example, you have 10 items and you need to do something to each of those 10 items. An … | |
Re: [QUOTE=caged_fire;1333661]The warning seems accurate. I don't think you can simply return an array because what you are doing is (as the warning states) returning the address of buffer. You should perhaps try returning an array pointer?[/QUOTE] They are already returning a pointer, that's why there is an issue. You can't … | |
Re: You haven't shared the class definitions (that I can see). Unless dateInception is a member of Actor, you should be getting a warning from your compiler about using an undefined object. Isn't this the same question you asked in [URL="http://www.daniweb.com/forums/thread311942.html"]your other thread[/URL]? | |
Re: I don't think I would actually make them part of my resume, but you will want to submit them as an enclosure or attachment. Just make sure you some how direct the Personnel Manager's attention to the attachment/enclosure. This would generally be accomplished in your resume's cover letter. Generally, the … | |
Re: You should be able to do something like this with basic string-manipulation functions. But, [URL="http://www.daniweb.com/forums/thread78223.html"]the information here is a little lacking[/URL]. I think a better description of the command format, how the command is interpreted, and some sample code are in order. | |
Re: It's because all your response outputs are part of the default case of your switch. You only see them if you make an invalid selection. In addition, you only see them if you have ordered at least one (1) of the particular item reported. However, the structure of the program … | |
Re: If you know your input stream is clear, you could just throw in some sort of blocking input read, like a [iCODE]cin.get()[/iCODE]. That will make the program wait until some sort of input shows up on the input stream. | |
Re: Does this code use the STL queue (looks like it) or a custom-written one? Either way, it sounds like you are either missing a header, or you haven't resolved your namespace properly. | |
Re: I don't know if it will work, but try sending the '\a' character to an output some how. That's the escape/control character for "beep" in many environments. | |
Re: Did you post all of your code? The error is flagging line 39, but find() is called on line 36 of your post... I see nothing wrong with that line. That being said, vidit is correct. You don't have a prototype for find() before main() so it doesn't know that … | |
Re: What exactly is the title of Chapter 5? Can you share the exact wording of the question you are working on? Like StuXYZ mentioned, this definitely sounds like either an [I]Introduction to Vectors[/I] or an [I]Introduction to Arrays[/I] type of chapter. When working with arrays, you need to be mindful … | |
Re: [QUOTE=prvnkmr449;1333887]If you don't want store that value then just use simple variable for getting input from user by using loop and and three other variable for storing sum [CODE] int number,total,total_positive,total_negative; total=0; total_positive=0; total_negative=0; cout<<"Enter 10 number:"; for(i=0;i<10;i++) { cin>>number; if(number<0) total_negative+=number; else total_positive+=number; total+=number; } [/CODE] Best Of Luck.[/QUOTE] … | |
Re: I think that depends on your definition of "a little difference between them". Are there data differences, functional differences, or both? Do they have the same basic functionalities and just implement the functions differently? This sounds like a generalization/specialization relationship, which would tend to imply an inheritance structure, but more … | |
Re: You have carriage returns in the middle of your string literals, you can't do that. If you want the output to wrap to the next line, you need to insert a newline character '\n'. | |
Re: [QUOTE=Ancient Dragon;1334721]Not harsh -- tough love :) Normally you will want to break down the problem into its simplest parts, then code them one at a time -- divide and conquer style.[/QUOTE] Amen! I would suggest you study algorithm writing. You will be more successful if you come up with … | |
Re: I see a couple things: [list=1][*]You can't initialize a floating-point constant inside your class definition, some compilers allow it for integral types though [*]You haven't declared "global" versions of your static member variables. In order for a static variable to work, you must provide a "global" declaration/initialization for it:[CODE]class Example … | |
Re: How did you get this to even compile? I don't think either of those initializations is even legal. | |
Re: Then what you need to do is use a [URL="http://www.cplusplus.com/doc/tutorial/control/"]switch, or other similar logic/control structure,[/URL] to analyze what the user entered:[CODE] cout << "Here are your options:" << endl; cout << "1.\tOption 1\n"; cout << "2.\tOption 2\n"; cout << "3.\tOption 3" << endl; cout << "Enter an option: "; cin … | |
Re: I had a similar example in a book I just read (Beginning C++ Through Game Design). Perhaps try the same technique. First initialize i and j using values from your enums. Then when calling set() cast the values from int to either Value or Suit as necessary. From my book's … | |
Re: Well, you only want the average to print once and that's after you have shown all the grades. If I'm reading this correctly, you have 5 students, each with 3 grades. Something of this nature should take care of it:[CODE] for each student from 0 to 4 { //begin student … | |
Re: First, your declaration of badDrivePointer should probably be a pointer to a U32 object since that is what the vector is carrying, not ints. Additionally, according to your comments, a U32 is an unsigned type whereas an int is a signed type. Unless U32 is an inaccurately-named typedef for int, … | |
Re: You are using rows and columns as the size values for the array declaration on Line 12 when they aren't initialized. This results in undefined behavior. In addition, per Line 6, TwoDimArray is a 2-dimensional array of ints. Then, assuming that rows and columns were properly initialized, Line 12 declares … | |
Re: [QUOTE=caged_fire;1333335]That is entirely dependent upon you. What if you add a word later that exceeds your limit? I would suggest you allocate the memory dynamically so that you don't have to worry about what array size will work best. Anyway, If the largest has 8 characters then you need an … | |
Re: [URL="http://www.daniweb.com/forums/announcement8-3.html"]Nice wall of improperly posted code.[/URL] [URL="http://www.daniweb.com/forums/thread78223.html"]What is it and why is it here?[/URL] *Post Reported* | |
Re: By their very nature, files are slow, if you need a fast system, you should keep information that is frequently accessed in RAM. I would some sort of static data structure, then just keep pushing and popping pointers to your image objects. Just make sure you delete the popped object(s) … | |
Re: That would be because you didn't associate your implementations for add() and printAlpha() to your class definition. You need to use the scope-resolution operator '[B]::[/B]', just like you did with your MyBST constructor. | |
Re: I think you need to create the proper class definition first. Your initialization statement(s) on Line 19 don't match your class' constructor definition. I would be surprised if this compiles. [list=1][*]You need a semi-colon after the brace on Line 8. [*]You have not created the proper constructors. The compiler will … | |
Re: If you're only going to the hundredths place, try changing the epsilon to something larger, but still reasonable. | |
Re: [QUOTE=fire_;1332686]Hello. I know this is lame questinon but what is multi-if syntax? Like this: [CODE]if (a == 0) doSometihng(); if (a == 1) doSomething(); else doElse();[/CODE] Or like this: [CODE]if (a == 0) doSometihng(); else if (a == 1) doSomething(); else if (a == 2) doSomething(); else doElse();[/CODE] I'm useing … | |
Re: Here is a program, using your example structures, that will demonstrate for you:[CODE]#include <iostream> using namespace std; struct node { int data; node * next; }; struct myList { node * head; node * tail; int numNodesInList; //member functions etc, but no other member variables. }; const int LIST_COUNT = … | |
Re: Your intent is a little confusing, it sounds like you want to add multiple items to the same element of an array. Which is not directly possible. You mentioned using a linked list to do this. This would work, but you would need an array of lists. Each element of … | |
Re: As written, total() returns the value of sum, but that return value then gets discarded because you aren't doing anything with it. You have 2 options: [list=1][*]store it to a variable, then output the variable [CODE]int someInt = 0; someInt = total(num1, num2); cout << someInt;[/CODE] [*]output the return directly … | |
Re: It's probably easier to beat because you wrote the algorithms yourself. Since you wrote them yourself, you know how they "think" and can exploit them. If you want to start translating it to C++, I would recommend an online tutorial of some sort. [URL="http://www.cplusplus.com/doc/tutorial/"]This is one of the first ones … | |
Re: The first issue that I see is your headers and header guards. You haven't properly #included them where necessary and you have only guarded "Dice.h", but you forgot to guard "DieRoll.h". This is generally how you want to do it: Object.h[CODE] #ifndef OBJECT_H #define OBJECT_H class Object { private: int … | |
Re: Try [URL="http://www.cplusplus.com/reference/stl/map/find/"]map::find()[/URL]. You should be able to get an analyzable result from that. Then, if you get a response that means "not found", you can call [URL="http://www.cplusplus.com/reference/stl/map/insert/"]map::insert()[/URL] to add the key you were checking for. The std::map container stores instances of the [URL="http://www.cplusplus.com/reference/std/utility/pair/"]pair<> data structure[/url] (a templatized struct). You may … | |
Re: Are you referring to the addition operator (operator+) or to any operator that takes only one operand? There are 4 ways to overload operators, and which specific method you use depends on if it's a [URL="http://en.wikipedia.org/wiki/Unary_operation"]Unary operator[/URL] or a [URL="http://en.wikipedia.org/wiki/Binary_operation"]Binary operator[/URL] and whether it's a member function or not. To … | |
Re: As Milton mentioned, both struct and class exist so that C++ is backwards-compatible with C. Even though they function nearly identically, the "class" however, is an extension of the basic struct that allows C++ to continue to evolve and improve on the concept without breaking the backwards compatibility. [QUOTE=Schildt, "C++: … | |
Re: @Nick Evan: [B]>>[iCODE]for(unsigned short i = n_elements - 1; i > 0; i--)[/iCODE][/B] That's a good idea, but with that the OP can't access element 0 of the array because the loop won't run. I don't like couning on the overflow, but I think a better answer would be to … | |
Re: [B]>>How could you write several thousands of lines without knowing this basic rule of C/C++?[/B] Having an off day? Maintaining/Modifying someone else's code? @op As Mike said, with that declaration, there is no such element known as One[31]. That would be element 32 of the array, but there are only … | |
Re: Welcome to DaniWeb. This is a nice first post, good job. Keep it up. What you have posted is a function definition. When you write a function, how is the definition supposed to be formatted? [CODE] returnType functionName([parmType1 parmName1 [, ... [, parmTypeN parmNameN]]) { statements... [return returnValue;] }[/CODE] I … | |
Re: Can you use the extraction operator to pull floating-point values out of a *.csv without the commas messing up your ifstream? It seems like the stream would get corrupted by the invalid input character(s)... | |
Re: I don't see it mentioned, so I'm going to add. When you are finding a minimum or maximum value, it is advisable to initialize your "lowest"/"highest") variable (whatever it happens to be named) to the first value of your set as opposed to 0 or some arbitrary value. This simple … | |
Re: Can't help much for 2 reasons: 1. [URL="http://www.daniweb.com/forums/thread78223.html"]Is there supposed to be a question in there somewhere?[/URL] 2. [URL="http://www.daniweb.com/forums/announcement8-3.html"][B][COLOR="red"][noparse][CODE]...code tags...[/CODE][/noparse][/COLOR][/B][/URL] are your friend. [INDENT][CODE] #include <iostream> int main() { std::cout << "This looks nice, and is easily readable." << std::endl; return 0; }[/CODE] #include <iostream> int main() { std::cout << … | |
Re: [URL="http://www.cplusplus.com/doc/tutorial/operators/"]I think you may want to make yourself familiar with the compound assignment operators (+=, -=, *=, etc...)[/URL] I'm sure you can do this with a nested loop and a simple "toggleStatus()" function. | |
Re: It's just a multi-dimensional array of char... [CODE]//an array of char char charArray[80]; //an array of char* char* charpArray[80]; //OR //an array of arrays of char char mdCharArray[25][80]; //25 80-char arrays [/code] It's exactly like the main() parameter char *argv[] (which is another way to do it) Or did you … | |
Re: I don't know if VS2005 is the same, but in VS2008 you can go to [B][I]Edit->Bookmarks->Clear Bookmarks[/I][/B] to get rid of them. |
The End.