78 Posted Topics
Re: [QUOTE=VernonDozier;1468991]To the OP... You might want to consider starting a new thread. This one's pretty long. No one like me who hasn't been following this is going to go back through all the old posts, so no one new is going to comment probably. As far as portability, obsolete headers, … | |
Re: I don't understand this: [code] if (my_array != 0) [/code] What [b]exactly[/b] are you checking for, and for what purpose? | |
Re: [QUOTE=firstPerson;1468926]from what I can see your code is prefect. Bugs free, fast, and takes no memory space.and its portable. Congrats.[/QUOTE] I get a syntax error. | |
Re: If you're saying that you want to exit the J loop at that point [b]and not enter it again[/b], you could always add a bool statement and check on it before each j loop execution. | |
Re: You're correct, your array is going out of scope. You need to either pass your array by reference or by pointer. I suggest reference unless you explicitly need pointers. [code] void readArr(int rows, int cols, fArray& array) [/code] And that should do it. You need to add the reference to … | |
Re: Just an FYI, to make your code cleaner, you don't need to check if your input number is larger than nine, since logically a digit cannot be higher than 9. You only need to make sure your division doesn't result in zero. Also, remember what your division and modulation is … | |
Re: What's your question? It looks like you just copy pasted a code. Also, use CODE tags | |
Re: I'm sure [url=http://www.sgi.com/tech/stl/Map.html] std map [/url] does all that for you. If you need duplicates, use [url=http://www.sgi.com/tech/stl/Multimap.html] std multi map[/url]. | |
Re: What exactly are you trying to test? If you expect a variable to be something but aren't sure if it will be that, you should use an ASSERT macro. [code] #define DEBUG // Get rid of this once you're done debugging. #ifndef DEBUG #define ASSERT(x) #else #define ASSERT(x) \ //single … | |
Re: One thing I'd suggest, just from skimming the code, is to try to let your functions only deal with one student at a time unless you're comparing the two students. There's no need to plug 5 student objects into a function at once, and would look much cleaner and be … | |
Re: Your variables are most likely going out of range. There a few ways to correct this. One would be to have the functions return the values to plug in, such as: [code] //in main for (int i = 0; i != SIZE - 1; i++) A[i] = InputValue1(); //function int … ![]() | |
Re: Don't hit enter after each input. Enter literally tells the console to make a new line. A simple space will suffice to separate the variables. | |
Re: You're using the argc all wrong. The int main initialization as shown: [code] int main(int argc, char ** argv) [/code] Assigns the numbers of arguments in the console during the executing to argc and creates an array of arrays of characters (basically an array of strings) containing each argument, the … | |
Re: You may want to learn some about bitwise operators as well, bit reading makes converting from hex to decimal and back again easy as pie. | |
Re: [quote]4.) There's nothing wrong with your codes. What's wrong with "Go To"? What matters is the purpose and the content of your program. Think of the people who will use the program.[/quote] "Goto" and other sloppy design methods, while they may work, often lead to one when needing to fix … | |
Re: [QUOTE=kikirkou;1443670]Hi all A teacher of mine told me that when an object of a class is created then six things are created.He didn't told me which.I know the obvious 4 things 1)Copy constructor 2)Copy asignment 3)Constructor 4)Deconstructor I don't know anything else?Do you have ab\ny idea?I searched everywhere but i … | |
Re: The convention is pointers, or references. [code] //Passing a variable via a reference! #include <iostream> using namespace std; void swap(int & x, int & y); int main() { int x = 1; int y = 6; cout << "\nBefore Swap, in Main: " << x <<" "<< y << "\n"; … | |
Re: Is there any particular reason you can't use a vector? Because it seems that iterators would do all that for you. Or a list, if your planning to constantly access different points. I'm sure someone could figure out a way to do it, but it would ultimately feel needless since … | |
Re: I'd suggest learning how to use vectors, since after doing so you'd have a more powerful array that, once learned, is easier to use. With a vector, you could just write: [code] mArray.size(); [/code] And there ya go. | |
Re: Hmmm, Perhaps the dynamic_cast pointer could achieve the desired result? | |
Re: [quote] [code] auto item = new AoE2Wide::Item{Pos, rf, "", ""};[/code] [/quote] Your declaration of "Item" is lower case here, though the class itself is uppercase. [code] auto Item * AoE2Wide= new Item(Pos, rf, "", "");[/code] Does this work? Or am I misunderstanding your intention? I'm pretty sure you can't use … | |
Re: [QUOTE=MasterGberry;1439421]When I did the & it wouldn't work. The problem is I am using a private ref class, not a standard class, which I read is different...[/QUOTE] Could you post the class declaration? I think the biggest issue you're having is your constructor doesn't match the declaration, though I really … | |
Re: I think the problem is that you're checking if the numbers are even [b]every time[/b] even though this is in no way necessary. If your first number is even, you can't subtract 2 to get an odd number. See here: [code] #include <iostream> using namespace std; int main() { int … | |
Re: Did your books teach you how to declare functions? Look for something on "Prototypes". It SHOULD be in the functions section. Is it necessary in this particular case? No. But is it a good habit that you should become accustomed to? Absolutely. | |
Re: Remember whitespace. The ";" operator is what the compiler uses to identify a new line. When you write: [code]int grade1 = 0; 30; [/code] The compiler reads it as: [code] int grade1 = 0; //end of the variable!! 30; [/code] If you want to compare between to numbers (0 - … | |
Re: One temp variable. [code] a = temp b = a b = temp [/code] | |
Re: Here, I'll give you the logic, and I'll leave it to you to write the program: For each digit, you need to check if one is bigger than the other, if it is, set a variable to define that string as the bigger one. This variable should only be assessable … |
The End.