What’s the difference between primitive and reference types?

From book OCA JAVA SE 7 Just as men and women are fundamentally different (according to John Gray, author of Men Are from Mars, Women Are from Venus), primitive variables and object reference variables differ from each other in multiple ways. The basic difference is that primitive variables store the actual values, whereas reference variables … Read more

What do the ampersand ‘&’ and star ‘*’ symbols mean in Rust?

Using * to dereference a reference wouldn’t be correct in C++. So I’d like to understand why this is correct in Rust. A reference in C++ is not the same as a reference in Rust. Rust’s references are much closer (in usage, not in semantics) to C++’s pointers. With respect to memory representation, Rust’s references … Read more

Understanding Java’s Reference classes: SoftReference, WeakReference, and PhantomReference

The Java library documentation for the java.lang.ref package characterizes the decreasing strength of the three explicit reference types. You use a SoftReference when you want the referenced object to stay alive until the host process is running low on memory. The object will not be eligible for collection until the collector needs to free memory. … Read more

Error message “Strict standards: Only variables should be passed by reference”

Consider the following code: error_reporting(E_STRICT); class test { function test_arr(&$a) { var_dump($a); } function get_arr() { return array(1, 2); } } $t = new test; $t->test_arr($t->get_arr()); This will generate the following output: Strict Standards: Only variables should be passed by reference in `test.php` on line 14 array(2) { [0]=> int(1) [1]=> int(2) } The reason? … Read more

Can we reassign the reference in C++?

ri = j; // >>> Is this not reassigning the reference? <<< No, ri is still a reference to i – you can prove this by printing &ri and &i and seeing they’re the same address. What you did is modify i through the reference ri. Print i after, and you’ll see this. Also, for … Read more

Does foreach() iterate by reference?

Yes, obj is a reference to the current object in the collection (assuming MyClass is in fact a class). If you change any properties via the reference, you’re changing the object, just like you would expect. Be aware however, that you cannot change the variable obj itself as it is the iteration variable. You’ll get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)