Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2008-09-17 13:47

1) Why do people not like C++?
2) Is C++ a good language to learn programming? Mind you, you don't need to use any of the advanced features.

Name: Anonymous 2008-09-24 12:50

>>59
object-instance variables are available to the inner class methods
That's not a closure either, it's a scoping benefit. The idea behind a closure is that the environment is captured and persists, such that it can be called later. Now, I'm not a Java person, so feel free to clarify me on this, but given the following code --

class Outer {
    int m_var;
    class Inner {
        int get() {
            return m_var;
        }
    }
    Inner get_inner() {
        return new Inner();
    }
}

Outer o = new Outer();
o.m_var = 1;
Inner i1 = o.get_inner();
o.m_var = 2;
Inner i2 = o.get_inner();


You're saying that the value of i1.get() == 1 and i2.get() == 2, correct? I was under the impression that Java did not save the environment (and thus i1.get() == i2.get() == 2) in which case it isn't a closure.

I don't have a java compiler installed. How does the (syntactically correct version of this) code behave?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List