1,358 Posted Topics
Re: We aren't going to do your coursework for you. In fact, the site's rules, which you obviously didn't read, forbid it. If we did the work for you, what would you learn? Answer: You would learn nothing. If you start your work, and can provide evidence that you have tried … | |
Re: Something is bothering me about your situation, I have a sneaking suspicion there may be a design issue. As far as I know, and as I understand your query, what you have demonstrated as your specific intent is not possible, but there are things you can do to clean up … | |
Re: Your error is on line 256. :P In case you didn't realize it, that was sarcastic. You may want to consider actually showing us your code, we're not psychics. (Although, WaltP seems to think he is ;)) | |
Re: Unfortunately, the forum rules require that we obtain from you evidence of your own effort before we can help, and there really isn't any here. [URL="http://www.daniweb.com/forums/announcement8-2.html"]Please see this.[/URL] Besides, if we don't see what you've done, we have no way of helping you anyway. We're not mind-readers; we assume a … | |
Re: A C++ namespace is not simply extra syntax and/or overhead, it's a system/mechanism within the language that is designed to prevent name collisions. The std namespace is enormous, every compiler-provided variable/constant/function is contained within it. When you say [icode]using namespace std;[/icode], you make all of those names visible to your … | |
Re: Have you tried opening the file in binary mode? When you open a file in binary mode, the end-of-line character(s) aren't converted when read/written... | |
Re: [B]>>Write a value-returning recursive function that uses the DigitSum function of part 1 to compute the single digit to which the int arguments digits ultimately sum.[/B] This is a weird wording. It sounds like you need another function, which I'll refer to as "findMinDigitSum()", that is recursive, but each recursion … | |
Re: You can, but it's not generally advisable to #include a *.cpp file. What are you trying to do? | |
Re: :confused: You're really not making much sense. It seems you want the "outer" vector sorted based on the contents of the "inner" vectors, and you want the contents of the inner vectors to be stable. Is there a reason you are using vectors to store a specific "person"'s information? I … | |
Re: It is advisable for you to get a grip. This type of post is extremely unprofessional and immature. Your values aren't all coming to zero (0). They are initialized to 0 when the program starts, which they should be, but they get modified as it executes:[QUOTE=program] 0 0 1 0 … | |
Re: It depends on how they were written. C++ is a cross-platform language. You can use it to write for any platform that has a C++ compiler developed for it. The big question is whether or not OS-specific libraries are used by the program. If they were, you're likely to have … | |
Re: Good to know. Is there a question in there somewhere?? | |
Re: An error like that typically means you are overrunning the limits of an array and corrupting memory used by other parts of your program or other parts of your system. [CODE] const int NUM_PLAYERS = 5; Team player[NUM_PLAYERS]; //... for(index = 0; index <= 5; index++) { }[/CODE] Your array … | |
Re: The way this is usually done is with an "account" type that has a "balance" member and "deposit" and "withdraw" methods. Are you familiar with functions? I think it would be advisable to create deposit and withdraw functions that handle the manipulation of the account(s) for you.:[CODE] struct acct { … | |
Re: You'll have to detect a "fail" or "bad" state on the input stream, then flush and reset it. [URL="http://www.daniweb.com/software-development/cpp/threads/90228"]Read this thread.[/URL] | |
Re: There are 2 ways to do it. You can wrap the function in a loop and simply store the return of the function to an element of the array, or you can pass the array to the function as an argument and handle all of the input and storage directly … | |
Re: Please be specific. Simply saying "It keeps giving me an error message" is an almost completely useless statement. What is the specific error? For starters, you clearly don't know how arrays don't work. The declaration:[CODE] std::string date[9][/CODE]declares an array of 9 strings numbered 0-8, not a 9-character-long char array. Thus, … | |
Re: I don't do GUIs yet, so I really can't say, but I suspect that will depend on what you want to do with your program. You may want to share that information. | |
Re: The array-index operator is actually a type of de-referencing operator, like * or ->, that's specific to arrays. The operator has lower operator precedence than the other de-referencing operators, so it behaves strangely in these situations. You need to get to the element before you try to dereference it. Have … | |
Re: Your phrasing "I don't know what variable or how the TFaculty objects are being placed into memory" makes it sound to me like what's confusing you is actually the dynamic allocation (the "new" operator), not the virtual functions and polymorphism. When a program is running, it accesses two (2) different … | |
Re: Your code's current formatting leaves something to be desired, it's ineffective and inconsistent, so you've made a common rookie mistake. You've mis-matched your braces. Here is your code reformatted for better readability:[CODE] #include <iostream> #include <conio.h> #include <cmath> using namespace std; double radius; double circumfrence; double area; double diameter; int … | |
Re: [QUOTE=arkoenig;1522922]I suspect the solution is [CODE]std::vector<passenger*>& passenger_queue::passengers_at_floor(int floor_) [COLOR="Red"]const[/COLOR][/CODE] The point is that at present, passengers_at_floor is permitted to modify its object, but you're passing it a const object, namely the key from a map. So you need to add const to the definition of passengers_at_floor, as a promise that … | |
Re: You're about the third person I've seen ask a question like this the last couple days. This must be some sort of exercise for a class. What is the focus of your current chapter? The behavior you are seeking is certainly possible; odd, but possible. You could do it through … | |
Re: Well, your code as posted is not readable. So, you can start by re-posting your code within [b][noparse][code]...code blocks...[/code][/noparse][/b] to make it readable. The error means that you are most likely missing a '}' somewhere after that point. | |
Re: [CODE]if (cin.fail()) { cout << "Bad input, please enter another positive integer (use cnt-Z to quit)" << endl; cin >> number; return 0; }[/CODE] To start, this is an if, not a function. That return terminates your program. You'll have to get rid of it. Once you've corrected that, look … | |
Re: Do you have to consider values that are less-than the "target" value as well, or just values that are greater-than-or-equal-to the "target"? Are the array values randomly-generated, or are they pre-determined values as part of the program specification? Are there max/min legal values for the "target" value? | |
Re: Your problem is that you are attempting to use identifiers declared as local to main() inside of functions that they do not exist in.[CODE] void someFunc(); int main() { int anIntInMain = 15; //declare an integer local to main() someFunc(); return (0); } void someFunc() { int someTotal = 0, … | |
Re: Is there any more syntax directly before or after this? This almost looks like part of a C-style bit field... | |
Re: >>represent each denomination by a class(eg: $5Class, $10Class etc.). Here is your answer right here... If you want to create an inheritance hierarchy, a good place to start is your description of what an object [B]is[/B]. A five-dollar bill [B]is a[/B] monetary denomination representing a value of $5. An example … | |
Re: What exactly is this program? Why do you need all this interconnected access? This sounds like a very long series of very bad design decisions... | |
Re: Borland is pretty old, I've never used it, so I can't give you specifics. But it looks like your project isn't configured correctly for a Windows API program. You'll have to look through your project's configuration to find the setting that tells the compiler the name of your program's entry … | |
Re: Programming is about decomposing large problems into smaller problems. You need to solve the small problems, then combine the small solutions into a solution to the larger problem. What do the different variables and portions of the equation represent? You should be able to create an "compounding" (or similarly named) … | |
Re: You might want to try to use Run-Time Type Identification. [URL="http://www.cplusplus.com/reference/std/typeinfo/"]The <typeinfo> header[/URL] is useful for this. I'm not sure how well it will work because you're using it on a pointer to a subclass though. The function you'll want is typeid(), but it's rather obscure and really not very … | |
Re: [QUOTE=w1mark;1514994] I know 2 bits can have the binary combinations 00, 01, 10, & 11, but does it really only store 3 combiations? Does this have to do with you don't count 00 as it would be the special null character?[/QUOTE] I uses all of the combinations available to it, … | |
![]() | Re: [QUOTE=HASHMI007;1514660]no dear i want to take values of x & y bye another function.[/QUOTE] What do you mean by "I want to take values of x & y by another function"? Do you mean that you want to input them in point::set(), then send them to point::init() for the final … ![]() |
Re: It's not even that, it's a pseudocode algorithm. It's up to you to translate it to C++ code that behaves similarly and meets your objective. No one here is just going to hand you the solution on a silver platter. Also note that most C code is also perfectly valid … | |
Re: Speaking of link spam.... Nice signature. 10 of your 12 posts are within the last hour. EDIT: Oops, Nick beat me to it... | |
Re: Um... We're willing to help, but we're not stool pigeons. You actually have to do something yourself first. Have you attempted any of your own debugging? If so what have you tried and what have you found? Are you getting compiler errors? What are they? etc... | |
Re: It looks like it's related to your definition of Position. How is it defined? EDIT: Oops, Narue beat me to it... | |
Re: I really don't see anything wrong with the lines you have mentioned as suspects for the problem. They all appear to be properly-written output statements. Your issue is is actually an input issue. It's caused by the input stream getting corrupted. What is struct emp intended to represent? It looks … | |
Re: You'll need to adjust your output field width, and possibly your output alignment. Look into the options provided by [URL="http://www.cplusplus.com/reference/iostream/manipulators/"]the <iomanip> header[/URL]. | |
Re: This is essentially what jonsca is telling you to convert your algorithm to:[CODE] int readRecords = 0; while (/*read first line of pet record*/) { //read and process remaining lines of current pet record; ++readRecords; //increment your record counter } for (int i = 0; i < readRecords; ++i) { … | |
Re: Well, considering that this is an error report, you may want to consider [URL="http://www.cplusplus.com/doc/tutorial/exceptions/"]try/catch blocks and exceptions[/URL]:[CODE] try { //some code //some code //ERROR throw errorType } catch (const errorType &e) { cout << "ERROR: " << e.what() << endl; }[/CODE] | |
Re: Yes, you can. It's called [URL="http://en.wikipedia.org/wiki/Common_Gateway_Interface"]Common Gateway Interface (CGI)[/URL]. I don't do anything with it though. | |
Re: What sort of project are you working on? There are several different concepts/objects you can apply the term "flag" to. In general, a "flag" is used to either indicate some state or trigger or prevent certain actions... You'll have to be more specific about your situation... | |
Re: [QUOTE=iamcreasy;1505334]I also noticed something, [CODE]int main() { int x; int u = x; return 0; }[/CODE] This code runs perfectly fine on GCC 4.4.1 but doesn't on VCC, that comes with VS 2008 express edition. :S This is confusing![/QUOTE] That's a behavior that is compiler-dependent. I don't think there is … | |
Re: So what exactly are you having trouble with? All that I see here is a wall of text containing 2 assignment dumps and a poorly-formatted (meaning hard-to-read) code dump. Unless I missed it, I don't see a good description of what your issue is and what you would like us … | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]I'm sorry, but we're not rent-a-coders.[/URL] If you would like help troubleshooting your own code, we'd be more than happy to help. Please post the relevant portions of your code and what your issue(s) is/are. | |
Re: [URL="http://www.daniweb.com/forums/announcement8-2.html"]What have you done so far?[/URL] Solving this will require the use of 2-pair of nested loops... One pair handles the taper out to the right, the other handles the taper back to the left. |
The End.