389 Posted Topics

Member Avatar for iConqueror

> pipelining and branch prediction at the CPU level maybe??? Branch prediction seems like a pretty good candidate. Note that the if condition `data[c] >= 128` will randomly switch between being true and false when the array is unsorted, but when it is sorted it will be false consistently until …

Member Avatar for ~s.o.s~
1
371
Member Avatar for king.umair523

A pointer is the address of a variable (or the address of an array slot, the address of a struct member etc.). For as long as the pointed-to variable is alive, you can access its value by dereferencing the pointer.

Member Avatar for tenzinlol
0
142
Member Avatar for kamilacbe

> Abstract classes are sort of the C++ flavor of what is traditionally called "Interfaces" in the Java/C# OOP terminology. I'd say they're the C++ flavor of what Java and C# call abstract classes. A C++ abstract class wouldn't translate to a Java/C# interface unless all the members are purely …

Member Avatar for sepp2k
0
132
Member Avatar for mayank.mittal.3954
Member Avatar for Hiroshe
0
300
Member Avatar for moaz.amin.37

Because you're using `i++`/`++i` as a statement on its own without doing anything with its value. The side-effects of `++i` and `i++` are the same, only the value differs. So if you don't use the value, there is no observable difference.

Member Avatar for sepp2k
0
472
Member Avatar for nouth

> how can I delete the file if it just becomes unlinked? When you say "delete", what exactly do you mean? Scrambling the file? Because when most people say "delete", they mean "removing the file system entry", which is exactly what remove/unlink does. > Also I haven't tried to yet, …

Member Avatar for Gribouillis
0
265
Member Avatar for sana.f.qureshi_1

Can you explain a bit what you code does any why you think it should do more than discarding one character after it sees a `{`? > You need to shove it onto the stack so you can push and pop the curly brackets. DFAs don't have stacks, so I …

Member Avatar for sana.f.qureshi_1
0
180
Member Avatar for Garidius

To iterate two arrays in parallel, you can use: array1.zip(array2) do |element1, element2| # ... end

Member Avatar for Garidius
0
446
Member Avatar for DkgMarine

First of all `ptr` is an array (of pointers), not a pointer. So you can't assign to it. Second of all, even if it were a pointer, it wouldn't be an int pointer, so casting the result of `malloc` to `int*` is wrong because that's the wrong type (also: don't …

Member Avatar for DkgMarine
0
2K
Member Avatar for zahra97

The problem is `c "and the new skill value is"`: there's only a space between `c` and the string - no comma.

Member Avatar for Daemon_CC
0
352
Member Avatar for iblanq

In Visual Studio you can press Ctrl + F5 or Shift + F5 (I don't remember which one) instead of just F5 to run your application in a console window that does not close. In most other IDEs the output will either show up in a tab or a window …

Member Avatar for Ancient Dragon
0
320
Member Avatar for Garidius

Put your code in a method that takes the hash as an argument, then define the hash after the method and call the method at the end.

Member Avatar for Garidius
0
235
Member Avatar for Sarkurd

When `i` is 0, we get `arr[num[0]] += 1`. `num[0]` is 1, so we get `arr[1] += 1`. By the same logic we get `arr[4] += 1` when i is 1 and so on. So no, it doesn't increase each element of `arr` by 1. Rather it increases each element …

Member Avatar for Sarkurd
0
309
Member Avatar for abaddon2031

As the error message correctly points out, it is indeed not a inside a loop. In fact there is no loop anywhere in your function.

Member Avatar for abaddon2031
0
242
Member Avatar for vishalonne

What is `random`? It's not a standard function. Did you define it yourself or does it come with Turbo C++? Anyway this `random` function probably needs to be seeded just like the standard `rand` function does. So if you don't provide a seed, you'll get the same sequence of random …

Member Avatar for vishalonne
0
272
Member Avatar for COKEDUDE

Also asked (and answered) [here](http://www.dreamincode.net/forums/topic/345231-pointer-question-of-function/).

Member Avatar for sepp2k
0
124
Member Avatar for smitsky
Member Avatar for smitsky
0
235
Member Avatar for trantran

> A node needs to point to another node, not to a DATA. It does. `node<DATA>*` is a pointer to a node. > Why not just use the following (apparently satisfactory) structure I haven't read the book, but presumably the solution presented hides the implementation of the nodes, whereas your …

Member Avatar for trantran
0
822
Member Avatar for Labdabeta

You do not use parsing algorithms to generate a list of tokens. The list of tokens is the input to the parsing algorithm. The output of the algorithm is generally an AST or some kind of intermediate representation of the code (or in some cases even the end product of …

Member Avatar for Labdabeta
0
303
Member Avatar for admiri92

Pointers are iterators (random access iterators to be specific) and they are in fact commonly used as such. For example `std::vector<T>` uses `T*` in most (possibly all) implementations (except in the case of `vector<bool>`, which is a special case). On the other hand there are many iterators that aren't pointers. …

Member Avatar for Moschops
0
252
Member Avatar for daniel.benniah

> I suspect the OP is compiling it as C++ where string is very likely to cause issues due to potentially being exposed as a type name. Why would it be likely to cause issues in C++? `g++` doesn't complain about the OP's code, even if I add `#include <string>` …

Member Avatar for naveen1993
0
565
Member Avatar for Pyler

Yes, `cup1` is an object (or rather it's a variable referring to an object - just like `cup2`). The biggest difference between `cup1` and `cup2` is that, if the `Coffee` class defines public methods in addition to those declared in `CoffeeInterface`, you will be able to call those on `cup2`, …

Member Avatar for JamesCherrill
0
248
Member Avatar for bignobela

I think the problem is that it does not recognize `uint8_t` as a type name because the `stdint.h` header was not included. That would explain why the error happens "before 'r'", rather than on line 1 (also I believe that (AVR-)GCC is the only compiler that you can use to …

Member Avatar for sepp2k
0
175
Member Avatar for Vasthor

Is `elements` a collection of string pointers or of strings? Judging from the error messages I'd say it's the latter, so your lambda needs to take a string or string reference as its argument. Since `destroy` takes a pointer, you'll have to pass a pointer to your string to it. …

Member Avatar for mike_2000_17
0
158
Member Avatar for daniel1977

`num1obj` has not been initialized and is thus neither pointing on the stack nor on the heap - it is pointing nowhere at all. Therefore dereferencing it invokes undefined behavior. Note that this is in no way specific to objects. If you dereferenced an int pointer that you did not …

Member Avatar for sepp2k
0
134
Member Avatar for TheFearful

Can you clarify what exactly you don't understand? The arrow means assignment, `for i <- x to y` means a for loop that iterates `i` from `x` to `y` and everything else seems to be the same as in C (i.e. `/` is division, `[]` is array access etc.). One …

Member Avatar for Schol-R-LEA
0
321
Member Avatar for 21345570

An immutable object is an object whose state can't be changed in any way through it's public interface. So it has no public variables and none of its public methods change any of its variables. One example of such objects are strings. You'd use those object like you'd use any …

Member Avatar for sepp2k
0
57
Member Avatar for 21334929

If you declare a variable as being of type `Object`, you're not going to be able to call any methods on that object other than the ones defined in the `Object` class (or pass it as an argument to any method that takes something other than `Object` as their argument) …

Member Avatar for sepp2k
-1
120
Member Avatar for brett.warren.1612

You're counting all multiples of 15 twice (once as multiples of 3 and once as multiples of 5).

Member Avatar for brett.warren.1612
0
120
Member Avatar for !@#$

You need the `def` keyword to define methods in Ruby. The reason that you need a keyword for this is that the creator of Ruby decided that was the most convenient syntax for method definitions.

Member Avatar for sepp2k
0
108
Member Avatar for rithish

Also you need to forward-declare your factorial function or define it before the main function.

Member Avatar for Reverend Jim
0
154
Member Avatar for yann.bohbot.9

> Instead of creating an array and a pointer just create a pointer and allocate memory. Why do you find that preferable in this case? str = (char *)malloc(sizeof(char)*20); // for 20 characters There's no need to cast the return type of `malloc`. Void pointers are implicitly castable to any …

Member Avatar for sepp2k
0
129
Member Avatar for COKEDUDE

VLAs are perfectly valid in C99 and "GNU89" - the only reason it wouldn't work with gcc/MinGW is if you explicitly set the standard to C89. And it doesn't work in VS because Visual Studio's C support is completely outdated. Oh and I should mention that this question has also …

Member Avatar for Ancient Dragon
0
264
Member Avatar for Doogledude123

> The problem is that it is taking away too much, double the cost System.out.println("Calc: " + this.curGold + " - " + goldValue + " = " + (this.curGold -= goldValue)); this.curGold -= goldValue; In the above code you execute `this.curGold -= goldValue` twice (once in the print statement …

Member Avatar for sepp2k
0
305
Member Avatar for V3N0M

How exactly did you install GHC? Did you install anything Haskell-related other than the main GHC package? And what's the exact error message you're getting?

Member Avatar for V3N0M
0
172
Member Avatar for mgold

> I believe that H(t1) stands in for a list of all the synonymes of t1 According to the paper it stands for "a set of tuples (h, f), where h is a hypernym and f is the number of times the algorithm has found evidence for it". So `n` …

Member Avatar for sepp2k
0
283
Member Avatar for thenewguy1

> I don't know of any built in pow function in Haskell Why don't you count `^` as a pow function? > powthing :: Int -> Int Unless you have a good reason to prefer `Int` over `Integer` (like you know for a fact that your use of `Integer` is …

Member Avatar for sepp2k
0
376
Member Avatar for kenjegalee

Let's say you have 25c and can use the 10c and 5c coins. Since 15 is greater than 10, you may use a 10c coin. If you do, you have 15c left (for which you again may or may not use another 10c coin). If you don't, you still have …

Member Avatar for sepp2k
0
380
Member Avatar for kent.johnstone_1

When declaring a variable, preceding the variable name with a `*` makes it a pointer. Preceding it with a `&` is illegal (in C - in C++ it makes the variable a reference). In an expression `&` takes a variable and produces a pointer to that variable, whereas `*` takes …

Member Avatar for kent.johnstone_1
0
423
Member Avatar for asif49

`copyOfX` is not a copy of `x` - it's a reference that refers to the same object that `x` refers to. If you want a copy, you need to explicitly create a copy, for example by invoking a copy constructor (assuming one is defined) like this: X copyOfX = new …

Member Avatar for JamesCherrill
0
152
Member Avatar for inspire_all

> I know that NP problems can't be solved in polynomial time. Since NP is a superset of P that can't possibly be true for all problems in NP. It is likely that NP-hard can't be solved in polynomial time, but that's an open question (NP ?= P), which has …

Member Avatar for amina.bm
0
241
Member Avatar for nouth

You can also use `for animal, noise in` instead of `for tpl in`. Then you can use `animal` and `noise` instead of `tpl[0]` and `tpl[1]` respectively.

Member Avatar for vegaseat
0
249
Member Avatar for inspire_all

The relation is that the record is stored on the stack. PS: This happens for all function calls (that aren't inlined by the compiler), not just recursive ones.

Member Avatar for sepp2k
0
122
Member Avatar for pheonixkid

Are you sure that the warning doesn't say "makes integer from pointer" rather than "makes pointer from integer"? I have no idea why it would say the latter for your code and my compiler at least says the former. The reason for that warning is that the elements of `argv` …

Member Avatar for Ancient Dragon
0
2K
Member Avatar for ambert123

Do you think it's true or false? What have you trieed to prove or disprove it? What's the definition of big-Oh - how would `2^(2^n)` need to relate to `2^n` for `2^(2^n)` to be in `O(2^n)`?

Member Avatar for alexstone
0
199
Member Avatar for ik1610

In your example code you only push one tree into the vector, so that's not enough to reproduce your problem. My guess is that in your real code you have a loop around lines 3 to 10. So at the end of each iteration of the loop, `myRBTreeCopy` goes out …

Member Avatar for sepp2k
0
307
Member Avatar for strongard63

I'm not quite sure I understand the question. You're simulating the game of life, so, at each step, you have a grid containing the live and dead cells, right? So just iterate over that grid and count the cells that are alive.

Member Avatar for strongard63
0
114
Member Avatar for nitin1

> When ever a multiplication code is called the compiler will perform inner addition operation. What? It might have been common for CPUs to not support multiplication over 30 years ago, but I doubt very much that any such CPUs exist now. So there's no reason for a compiler to …

Member Avatar for rubberman
0
261
Member Avatar for DarkLightning7

The error is because you call `sub2` first with `hd z` and then with `tl z` as the third argument. `hd z` and `tl z` have different types: If `z` is a list of `foo`s, then `hd z` is a `foo` and `tl z` is a `foo list`. For `foo` …

Member Avatar for DarkLightning7
0
1K
Member Avatar for trishtren

> '^' is a special character ONLY when used as the first character within square brackets `^` means "beginning of the line" outside of square brackets, so it does need to be escaped. You're right about `_` though.

Member Avatar for masijade
0
278

The End.