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

C++ Member Function Lookup

Name: Anonymous 2010-02-06 12:22

I'm reading `C++ Common Knowledge' to find out more about this fascinating pile of crap. I'm currently in the section `Member Function Lookup' and discovered this gem:

class Foo {
public:
        void x(int) {}
};

class Bar : Foo {
        int x; /* This is fuckin' private. */
};

int main()
{
        Bar bar;
        bar.x(3);
        return 0;
}


I understand what it does and why it does it, but what the fuck was Bjarne thinking when he decided this? If this is object-oriented programming, I'm Ada Lovelace. HIBT?

Name: Anonymous 2010-02-06 16:43

>>10
I don't know about C++, but I actually (ab)use the fact that there's a separate namespace for functions and variables in CL (well, there's also the package system which allows for even better control). For example, I almost always use "list" as a name for an argument representing a list on a function that's meant to just do some generic operation on lists. At the same time, "list" is also a function which just conses up a list. In Scheme and Lisp-1's, where there is a single namespace, people just name such arguments "lst"/"lyst" or similar to avoid shadowing the "list" function.

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