- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 253
- Posts with Upvotes
- 194
- Upvoting Members
- 128
- Downvotes Received
- 12
- Posts with Downvotes
- 12
- Downvoting Members
- 5
Re: If the user enters a number too large to fit into a long, LONG_MAX will be returned. If the user enters a number that's exactly LONG_MAX, LONG_MAX will also be returned. The first would be an error case, the second would not (in the case that `sizeof(int) == sizeof(long)` - … | |
Re: Which part of that assignment are you having trouble with? | |
Re: > Even if you make abc global, it still doesn't work in Visual Studio 2015 Because your function is returning a *copy* of abc and that copy is a temporary object that goes out of scope at the sequence point, just as deceptikon explained. > returnValue seems to point to … | |
Re: This has (hopefully) been answered here: http://www.dreamincode.net/forums/topic/398067-first-and-the-follow-compilers/ | |
Re: What you posted does not look like source code, it looks like what you might see when you open a binary file in a text editor. Presumably you downloaded the zcode file (which is a bytecode format), not the source code. I do not think the source code of Zork … | |
Re: Note that using a different extension won't prevent people from opening the file in a text editor. It'll just stop a text editor from being the default application that will open when you double click on it in your file manager (unless the user then selects a text editor as … | |
Re: > <for loop> ::= for ( <expression> ; <expression>; <expression> ) <statement> All three expressions in a for-statement are optional and from C99 onwards the first one may be a variable definition instead. Also note that the assignment specifically says that `<statement>` does not include composite statements (for whatever reason), … | |
Re: Using your first definition `account1.compareTo(account2)` will call `account2.name.compareTo(account1.name)` and using your second definition it will call `account1.name.compareTo(account2.name)`. So using the result of the comparisson will be the other way around and thus the sort order is reversed. | |
Re: This isn't what's causing your syntax error, but Java doesn't have a type named `sum` nor do you define one anywhere in your prorgram (unless you defined it in a different file that you didn't show), so `sum c` is a type error (both on line 7 and line 8). … | |
Re: The `>` operator is only defined for primitive types. To compare `Comparable` objects, use the `compateTo` method instead. | |
Re: It looks like the Ribbit class does not have a `userid=` method - presumably because you did not define one and the corresponding table does not have a `userid` column either. | |
Re: Any implementation will definitely *read* everything (well some languages have some kind of "stop here" token, which causes the impelementation to stop reading at that token, but in those case the stuff after would simply not be considered part of the program at all). Even if it did decide to … | |
Re: There's only a difference when you use the return value of the increment for something. So the two loops are completely equivalent. | |
Re: Please post a compilable and runnable piece of code that reproduces your problem. | |
Re: 2147483647 is the largest number that an int can store. When you convert it to float, it becomes 2147483648.0 due to floating point accuracies. When you convert that back to int, you'd get 2147483648, except that that's too large to fit into an int. So instead you get an overflow, … | |
Re: > In the program Why you used 0 in return 0 ; The return value of main is the program's exit code. If it is 0, that means that the program terminated successfully. A different return value means that the program failed. This distinction matters most in shell scripts: if … | |
Re: Your question seems to be missing some words. Did you mean "After returning true, does the for loop continue?" If so, the answer is no. When the return statement is reached, the control flow returns to the call site. | |
Re: When you don't specify the size of an array, the size is inferred from the initializer. So when you write `int arr[] = {1,2,3}`, that's the same as `int arr[3] = {1,2,3}`. Likewise `char formula[] = {'\0'}` is the same as `char formula[1] = {'\0'}` and equivalently `char fomula[] = … | |
Re: It'd have helped us if you had described in what way the code did not behave as expected, but your problem is that you access the matrix out of bounds (the matrix can hold 2x2 items, but you're trying to store 3x3). Also you're printing "1th" and "2th" when the … | |
Re: Syntax errors come with a line and column number as well as some indiciation of what's missing (or what's there that shouldn't be). So to find a syntax error you should look around the given line and column for anything that might fit the error message. If the message is … | |
Re: > I am not to properly understand why, and when we have to dynamic cast. Strictly speaking, you don't ever have to use `dynamic_cast`. You *can* use `dynamic_cast` when the castee is a pointer or reference to a class that contains at least one virtual member (that's what's meant by … | |
Re: If a file has never been added, it is untracked. Untracked files are not affected by anything you do with git (like switching branches). One way of looking at it is that, until you added the file, the file did not exist in any branch. Instead it existed in the … | |
Re: NP means a NTM can solve it in polynomial time (or equivelantly that a DTM can verify the result in polynomial time). Note that NP is a superset (possibly, but not necessarily, a proper superset) of P, meaning that everything in P is also in NP. A problem X being … | |
Re: > no instance of overloaded function "System::Console::WriteLine" matches the argument list argument types are: (const std::string) I've never used C++/CLI, but it looks like `std::string` is a distinct type from `System::String` and presumably `Console::WriteLine` only works with the latter as it is a .net method and `std::string` is a C++ … | |
Re: Whether you can parse each line individually depends on the language. I'd say in most languages, you'd need to parse the program as a whole. But yes, a simple (as in: non-JITing) interpreter generally consists of two phases: parsing and execution. > I suppose the code needs instructions on how … | |
Re: If you know how many elements you're going to add to the vector (or you at least have a reasonable upper bound), you can also use `reserve` to reserve the proper amount of memory up front, preventing reallocations. Then you'd have exactly one move constructor call per `push_back` and no … | |
Re: The `controller` variable is not defined within the `counter` method. You need to either pass it as a parameter or make it a member of the object (by doing `self.controller = controller` in the constructor) and then access it as `self.controller` instead. In the future please include any error messages … | |
Re: > Is {(1,1), (2,2), (3,3)} symmetric? transitive? Yes! Yes! Obviously I'm not your grader, but I'd expect that you need to give some explanation along with your answers to get a full score. Other than that you are correct. > Why is R = {(1,2), (2,3), (1,3), (2,1)} not transitive? … | |
Re: `gcc` produces a binary executable, not a shell script. To run it, type `./main.out`. | |
Re: No a char value can not be larger than what fits inside a char. However what getchar returns does not have to be a char value. It could also be EOF. Except for the missing `&`, your `scanf` line is perfectly fine. When `scanf` reaches the end of file (or … |