1,288 Posted Topics
| |
Re: You can trash your stack to the point that the bt information is lost. If you can build your programme to run on your Linux machine, run your programme under valgrind (be sure to have built a version with debug symbols) and if you're stomping all over your own memory, … | |
Re: Does your source code #include the header files? | |
Re: Yes. C++ can make your processor do anything and everything it is capable of doing. | |
Re: [QUOTE]but if you use a normal calculator , the answer should be 30.[/QUOTE] Does "normal" mean "broken" in this case? If that's what your calculator says, either it's broken, or you're not using it correctly. | |
Re: I really, really do not think you want to write your own compiler. | |
Re: Let's take a look at the function setadd. [B]void fraction::setadd(int num1, int den1, int num2, int den2)[/B] There it is. It takes one, two, three, four integer parameters. That means that when we call this function, we must give it four arguments, which must all be of type int. Something … | |
Re: A string* is a pointer to an object of type string. A pointer is typically the size of an int or two, but it's dependent on your system. You can find the size of any object with sizeof. For example, [CODE]string* someStringPointer; int size = sizeof(someStringPointer);[/CODE] I suspect you actually … | |
Re: This is a big OR statement. It says... If any of the following four things are true, execute the statement: 1) initialize == "off" && Iminor > 20 2) Imedium > 10 3) Isevere > 5 4) Ifatal > 0 You say that 2, 3 and 4 all come out … | |
Re: Show us the code you already have and which part you're having trouble with. | |
Re: If you mean those underlined variables to be strings, you have to put [B]"[/B] around them. [B]CBus::CBus(int a = 1995, char *b = "Sedan", char *c = "Mazda")[/B] | |
Re: [B]What kind of programmes I can built with?[/B] Anything. | |
Re: What happened to all the semi-colons? Have the brackets from your [B]if[/B] and [B]else[/B] vanished as well, or is the code above your actual code? | |
Re: If I have an object that carries out some clever mathematical calculations, and needs to maintain some internal variables to do so, it would be foolish of me to do anything with those variables other than hide them. If they can be changed directly by a user/coder, then the next … | |
Re: [QUOTE]how do you come up with it [/QUOTE] You come up with it by thinking about the problem and developing an algorithm to solve it in a methodical way that is appropriate to being turned into code. For example, I might look at this and think that the steps will … | |
Re: [B]"this is a string of base"[/B] is a string literal. A string literal is a constant. Your code is trying to directly change a string literal; do not try to change things that are constants. The C++ standard says [I]The effect of attempting to modify a string literal is undefined.[/I] … | |
Re: Aside from the issue of reading data from file, on line 24 you appear to be using the array of char called [B]marker[/B], but you've never put any values into that array. | |
Re: bullets is an array of pointers to Bullet objects. When you delete a bullet object, you are essentially marking the memory of that bullet object as available for something else - there is no guarantee that the memory is changed and it may well remain exactly as it was. The … | |
Re: What are the compiler errors? | |
Re: Where does the constant, incessant support for Dev-C++ come from? | |
Re: You have not provided the default constructor [B]Account::Account()[/B], and it seems something wants it. | |
Re: How about something like this? [CODE]cout << "userId is " << userID << endl;[/CODE] | |
Re: [CODE]string parseInputString (string) { string oneline; string last, first, result; oneline = last + ", " + first + "."; return oneline; }[/CODE] This function will always return ", ." because you never put anything in [B]oneline[/B], [B]last[/B], [B]first[/B] or [B]result[/B]. Also, whatever variable you're feeding to this function has … | |
Re: Because you never actually do anything to put numbers in totalCommission or basePay. It's just chance that they're set to zero. You're doing nothing with them. You made some functions to calculate these values, but you never call the functions. | |
Re: x->someMemberVariable is for accessing a member variable/function when x is a pointer to an object. x.someMemberVariable is for accessing a member variable/function when x is the object, not a pointer to the object. x->someMemberVariable is shorthand for (*x).someMemberVariable Use x->someMemberVariable when your x is a pointer to an object, use … | |
Re: We tend not to just give you working code. Is it that you don't understand the equation, or that you struggle with the C++ code? Note that C++ has a standard math library, but no math class. Do you have some kind of math class that you are to use, … | |
Re: Do you mean the output has to be a string, or do you mean that you're forbidden from using anything but a string in your code? | |
Re: There's really no trick to it. Take each function in turn and implement it. For example, the function [B]int Complex::getReal()[/B] returns the real part of the complex number. So, you need to write some code that [B]return[/B]s the [B]real[/B] of the object. | |
Re: This again. You're asking the wrong question. It isn't why does it close; it's why haven't you done anything to keep it open? [url]http://www.cplusplus.com/forum/beginner/1988/[/url] [url]http://www.daniweb.com/software-development/cpp/threads/12177[/url] | |
Re: Remove the .h from iostream.h - it it just #include <iostream> You have not specified a namespace, so cout and cin should not work - they should be std::cout and std::cin. If your compiler lets you get away with this, it really shouldn't. [B]main()[/B] is illegal - your compile should … | |
Re: [CODE]linkedlist::isMumber(double x)[/CODE] You need the return type on the front of that. | |
Re: You do not have anything set wrong on your PC. This is how Visual Studio works. Your programme gets made an an executable file. The executable file is run from the command line. If you open a console window and run it yourself manually by typing the name of the … | |
Re: As an aside, this is C++; you don't need to keep repeating "struct" every time you create a new instance of one. | |
Re: [CODE]bool done = true; while (!done)[/CODE] [B]done[/B] is true, therefore [B]!done[/B] is false, therefore the while loop will not execute. | |
Re: [QUOTE]1. Are data structures essentially classes minus methods which can preform actions on the memebers that are held inside?[/QUOTE] [QUOTE=007]A struct can't hide which variables are private or public but a class can. I think that is the biggest distinction.[/QUOTE] [B]That's completely untrue.[/B] Do not read the post above. In … | |
Re: [QUOTE]No, C is not used anymore much expect in OS development.[/QUOTE] There is more embedded hardware running C code than there are PCs running operating systems. Just because [I]you [/I]don't code in a language doesn't mean nobody does. | |
Re: How about simplifying your code a little? On the assumption that there are 49 elements in the array (i.e. it is a 7 x 7 array) [CODE]int numberOfSheep = 0; for (int i=0;i<49;i++) { if (*board[i] == 'S') numberOfSheep++; }[/CODE] Edit: This is not a complete programme. It needs a … | |
Re: You see this opening brace, "{", in your code? class Shop[B]{[/B] Where is the closing brace that goes with it? | |
Re: In your code, you are returning something called new_value. What is that? It does not exist. Return the value you want to return, not some made up value that does not exist. | |
Re: You can just use the forward slash key instead; it will work on all the common desktop operating systems. [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.16[/url] | |
Re: How would [I]you[/I] guess the number? Write out those steps, and that's your algorithm. It might be something along the lines of: Pick a number halfway between the minimum and maximum possible numbers. If correct, stop. If too high, change possible maximum to this guess minus 1 and start again. … | |
Re: This is dependent on your operating system. [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.17[/url] If you're using some kind of *nix and have termios.h available, [url]http://www.doctort.org/adam/nerd-notes/reading-single-keystroke-on-linux.html[/url] Otherwise, tell us your operating system and we'll point you the right way. | |
Re: [QUOTE]What libraries i should use to use the OS functions ????[/QUOTE] It depends on your OS. | |
Re: This function creates a [B]list[/B], named [B]q[/B], on the stack. That object [B]q[/B] is destroyed when you return from this function. If you want to return a pointer to an object, you will have to do something to ensure that the object exists after the function returns. This is commonly … | |
Re: [CODE]class vector { manipulateInCartesian (&vectorType); manipulateInSpherical (&vectorType); manipulateInCylindrical (&vectorType); vectorType add (vectorType, vectorType); vectorType multiplyByScalar (scalarVal, vectorType); vectorType dotProduct (vectorType, vectorType); vectorType crossProduct (vectorType, vectorType); }; [/CODE] Don't forget to implement the functions and define a vectorType. | |
Re: You see where you put [B]using namespace std;[/B] ? By doing that, you included a whole lot of already defined functions and classes. One of those is called [B]distance[/B], so you have defined [B]distance[/B] twice. This is exactly why slapping [B]using namespace std;[/B] on the top of everything without understanding … | |
Re: Just the header file will be useless to you without the all the other header files, source code and compiled libraries it uses. The complete set of all that, for Windows 7, is about a gig and a half's worth of download. | |
The End.