624 Posted Topics
I'm making an asteroids clone game, using GDI+ in C#. I don't understand why the asteroids wont move. They are supposed to rotate based on a member indicating rotation angle, and move in a direction based off of a member that indicates movement angle. But they don't do anything at … | |
Re: I disagree with rashakil. Using pointers properly can greatly increase the efficiency and speed of your code. Just compare C++ to C#. C++ programs run much much faster than C#, because C# doesn't support pointers (except in strange unsafe blocks). The reason your program is crashing is because your pointer … | |
Re: Pointer notation is slightly different than conventional array notation. It's just a syntactic issue, so I'm not afraid of doing some of your homework for you: [code=cplusplus] void ReverseArray(int* &intArray, int size) { //for each element up to "size" for (int i=size-1; i>=0; i--) { cout << "Element " << … | |
Re: That means you forgot to initialize your values when you declared them. (Usually this just throws a warning, but each compiler can be different). Just give every variable you declare a starting value, by putting it in brackets (), ie: [code=cplusplus] int iHoursWorked(0), iTime(0), etc... [/code] | |
Re: A class with a purely virtual function. (ie can't be instantiated) | |
I'm trying to right a red-eye reduction algorithm for an assignment at school. The user is asked to click on 2 eyes in an image, then the algorithm takes over and corrects the redness. The algorithm works just dandy, but I'm having a hard time capturing the actual location (in … | |
Re: I'm not sure I understand the question. Please clarify; are you wondering where to put the jpeg file itself so that it can be tested? Or are you wondering how to check if a file is a .jpg file? 1) Just call that function with a forced filename (a literal … | |
Re: [QUOTE=daviddoria;782237]Anyone know a good, simple set of classes to do thing like cartesian to spherical conversion, coordinate system transformations, etc? I wrote some of this stuff, but my code keeps breaking because of "special cases" that I have not handled. I just want to be able to use this stuff … | |
Re: If you have to use RTTI as part of the assignment, then google it. Otherwise do as the others sugguested. Implement in the base class (the one you derived the 2 accounts from?) a virtual method that returns a bool. Now provide an override in the 2 inherited classes, one … | |
Re: What they are trying to say is, it's bad practice to exit your program spontaneously. Objects would be left undestroyed, memory orphaned, and it just doesn't look professional. Instead, use logical blocks (if/else, switch, while, etc) to stream something like that (an exit condition) towards the final return call in … | |
Re: I don't think that would help the performance. If anything, it would just increase build time by about a few clock cycles (setting a const flag). If you actually broke down the code you write into assembly you'll see that const isn't used, it only means something to us as … | |
Re: Umm...and...what is the problem? And why did you create 2 accounts? That's not very good use of the server's spare resources. | |
Re: You can't just assign a const char * to anything... You are infact assigning an address, not a temp string. And I doubt those are your intentions... Instead use strcpy() or something similar. | |
Re: [QUOTE=kevinchkin;782231]Geez I don't know why do people have so much attitude on this forum. I was only asking for project ideas. I wasn't asking for project or something. People on this forum are acting like, they are all Gods and it's their responsibility to make sure every human is following … | |
Re: I would use a bit more structure than that. Put all that crap in main into a different function, like this: [code=cplusplus] //#includes and whatnot... int main(/*arg stuff or w/e*/) { while (Menu() != true) {} return 0; } bool Menu() { //some crap from the old main() //this is … | |
Re: How about you don't edit your posts to tell us it's solved. How about you post your solution. That way people can learn from your mistakes. Keep editing for fixing typos and improving clarity. | |
Re: Whats the actual question? A stack really doesn't take any implementing, non-dynamic (ie stack) variables are handled automatically (pushed and popped). There is a stack in the stl...but it's really not that useful... | |
Re: Well I can see a few issues with this code. First of all, when someone gets hit, i assume they would lose hp, not gain it. And as to the actual problem, the Boxer class doesn't contain a member called hp. The best way to do something like this is … | |
Re: [QUOTE=BevoX;773955]Well, a vector or list is similar to an array. They are a kind of sequence containers, and they expect real arguments. So, you can't create a list or vector, which holds lists or vectors. Read about them: [URL="http://www.cplusplus.com/reference/stl/vector/"]http://www.cplusplus.com/reference/stl/vector/[/URL] [URL="http://www.cplusplus.com/reference/stl/list/"]http://www.cplusplus.com/reference/stl/list/[/URL][/QUOTE] That's just wrong information! A vector can hold anything - … | |
Re: I would just getline() each line into a vector of strings, find() the cullprit, then change it via the iterator find() returns. then output the new vector to the file. i estimate a 10 line solution or less. | |
Re: I don't think the -> operator (or the . or & operator) can be overloaded =( | |
Re: Are you pushing ints into a vector, or strings? If your pushing 010 into a vector of ints your going to have issues. You're going to need to use stringstream to push numbers into a string then push those onto a vector. The binary numbers themselves can be generated with … | |
Re: [QUOTE=Salem;774585]> while(addresses>>link>>name) Having got to the end of the addresses file once, where do you think you'll start off from with the second word from the keywords file? Even for a short program, your indentation is mis-leading and needs work.[/QUOTE] If you are using VS2005+ press ctrl+a+k then f. This … | |
Re: Hmmm the only thing I can think of is...are you sure that you are catching the exception that you think you are? Maybe there's an internal one being thrown caused by trying to load the invalid image. I've never overloaded an exception myself, so this might be a dumb question, … | |
Re: Your map code seems fine. Maybe post more code, where s and v are declared. It seems like this wasn't copied and pasted, since there's a few program-busting spelling mistakes in it. You might want to fix those. | |
Re: [QUOTE=Phil++;774618]Hey, I'm trying to make a basic engine in Lua that prints out "Hello World" now I have downloaded lua and put the files include files into the same folder. But it won't compile. Is there a linker I need? Please help :( thanks[/QUOTE] You seem to have posted a … | |
Re: [QUOTE=Comatose;773140][url=http://www.letmegooglethatforyou.com/?q=C%2B%2B+md5+hash]Maybe?[/url][/QUOTE] Haha what a sweet website. | |
Re: [QUOTE=marco93;774571]No, it's a very bad example, because grid controls are native in Win32 and you don't need to re-invent the wheel. And here, it's not a grid, but a lv.[/QUOTE] Nothing wrong with re-inventing the wheel, so long as its either better or you learned something from it. | |
Re: Depends on what you're capable of! You should make it as challenging for yourself as possible without being unreasonable. Our final project is a 4 player tank shooting game played over a LAN using DirectX, perhaps you could do something similar? | |
Re: [url]http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt[/url] Alot of info on the mp4 file layout. | |
Re: Notepad++ is great for many code languages. It's much more lightweight than VC++, but it lacks alot of features (particularly a debugger and compiler/linker =P ) | |
Re: The reason for using const modifiers is for situations like this: [code=cplusplus] Point const X(5, 2, 3); Point Y(0, 0, 0); Y = X; [/code] Since x is a const, the previous version of your code will not work, but the new one will. But this isn't likely what fixed … | |
Re: How about...don't read the file twice!! It's practices like this that cause execssive wear on harddrives. Why not load everything in the file into memory (an array/vector)? You will find that RAM has much better read/write times than your harddrive... | |
Re: What does the default constructor look like (the one with no arguments). That could be causing a problem. Please post more specific code (the actual class perhaps?) and the incorrect result you are getting (error message? wrong output?). It is good c++ practice to always initialize an object with its … | |
Re: Lol. If you're going to ask people to do your homework for you, at least give a reasonable description of what it is you are supposed to do! (But still...don't ask people to do homework for you...) . Is this object oriented? Are you using a certain class/struct for the … | |
Re: [code=cplusplus] cin.ignore(cin.rd_buf()->in_avail()); cin.get(); [/code] Slap that on the end of the code. This will do the following: ignore all the available input from the cin (console) input buffer, then grabs a null terminated character (basically waits until you hit enter). | |
![]() | Re: ummm....lol. What a rediculous objective. Is this to be console based? No graphics whatsoever? If it is console based, I'd say that the contest is much too easy and find it hard to believe that an award is really being offered. ![]() |
Re: Is recursion really necessary for this? Whenever possible avoid using it. It's inefficient, hard to implement, and hard to debug. It seems as though the function recursively calls itself until it is at the end of the list, then it displays a line. In each recursive call, you should be … | |
Re: Show some effort by posting some of your own code. I'm not even sure what mergesort is supposed to do. | |
Well, this is for the same assignment as my last post. It's just a simple implementation of a bunch of Algorithm functions. It throws a runtime exception at the end saying the stack around the b variable was corrupted! I commented out all the lines with that use the b … | |
I'm working on an assignment for school where my teacher wants me to convert each member of an array of a class if it's int member is greater than 300. I can make it work for the first value of 300, since that's what find_if returns. But how do I … | |
Re: Why are you passing an array to displayLottery (in the declaration), it's not used in the method? Also, when you set the lottery you are only setting index # 6. And if you had properly passed your array from main it would be an out of range index (which will … | |
![]() | Re: You weren't very clear, and that isn't very easy to read, but i think you're building a sentinel loop. [QUOTE][code=cplusplus]while (choice != 'A' && choice != 'B'&& choice != 'C' && choice != 'D') { cout << "You must enter A, B, C, or D.\n"; cin >> choice;[/code] }[/QUOTE] There's … |
Re: Hmmm it seems your using a while loop to check if the input was valid. I would just throw an exception: [code=cplusplus] if (number <= 0) throw exception ("Invalid number"); //now do the factor testing loop for (int factor(2); factor <= (number / 2); ++factor) if (number%factor == 0) cout … | |
Re: lol...you wan't people to go through all that code and find what your having problems with? I think you should be more specific as to what the problems are, and maybe post a more relevant piece of the code. | |
Re: And for the second function, it will require an int argument. Make it something like this: [code=cplusplus] void Play(int); //declare it int main() { //call it Play(Menu()); ... } //define it void Play(int iChoice) { //put the switch here } [/code] | |
Re: Hmmm perhaps you should be comparing to position - 1, since 0 is counted. While something may be in 3rd in the list, it would be counted as 2nd since position starts at 0. Position will always equal the pos due to the above loop. I think a simple else … | |
Re: [code=cplusplus] if (stringa == "end") [/code] I think that's what you meant. | |
For a lab, my instructor asked us to include an assignment operator with our class, but to hide it. Does this mean to declare it as private and just leave an empty implementation? Is this common/useful? | |
I'm writing a function parser, which (hopefully) will be able to handle much more complex problems than basic operations. I've just completed the handling of the addition, subtraction, and brackets, but am at a loss of how to implement proper order of operations for multiplication and division. In order to … |
The End.