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

Sepplesfags, help!

Name: Anonymous 2008-12-08 18:34


template <class T>
class A
{
public:
    typedef T Foo;
};

template <class T>
class B
{
    A<T>::Foo foo;
};

int main()
{
    B<int> b;
    return 0;
}



test.cpp:11: error: type ‘A<T>’ is not derived from type ‘B<T>’
test.cpp:11: error: expected ‘;’ before ‘foo’


What the FUCK?

Name: Anonymous 2008-12-08 20:27

Thanks for the help. Now for the next WTF:


class A
{
protected:
    void Foo() const {}
};

class B : public A
{
public:
    void Bar(const A& a)
    {
        a.Foo();
    }
};


test.cpp: In member function ‘void B::Bar(const A&)’:
test.cpp:4: error: ‘void A::Foo() const’ is protected
test.cpp:12: error: within this context


I thought the whole point of protected was so that inherited classes could use certain member variables/functions, but keep them off-limits from others.

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