function in outside of public, private and protected.

1
2
3
4
5
6
7
class Foo{
    int x;

    public:
    private:
    protected:
};



Where does x belong to?

I saw bucky's template tutorial and he puts his template variables outside of pub, priv and proc.

1
2
3
4
5
6
template <class Z>

class Foo{
    Z x, y;
    public:
};


where does x and y belong to?

(also, I have another question, why is stackoverflow people so cocky?)
For a class, the default protection level is private

For a struct, the default protection level is public

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Foo
{
    int x;  // <- Foo is a class, so x is private
};

template <typename Z>
class Foo
{
    Z x;  // <- Foo is still a class, so x is private
};

struct Foo
{
    int x;  // <- Foo is a struct, so x is public
};

Topic archived. No new replies allowed.