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

C++ template help?

Name: Anonymous 2007-02-04 0:44

In the following program I want g() to be prototyped inside the class X and defined later.  I can't get g() to compile though no matter how many variations I try.  f() compiles fine.

template <typename T>
class X
{
public:
    class Y { };
    Y f() {Y y; return y;} //Okay function.
    Y g(); //Problematic function.
};

//Compiler Error Here: expected constructor, destructor, or type conversion before 'X'
template <typename T>
X<T>::Y X<T>::f()
{
    Y y;
    return y;
}


int main()
{
    X<int> x;
    x.f(); //This works.
    x.g(); //Call to problematic function.
}

Name: Anonymous 2007-02-05 9:36

>>8
Not under my definition of dynamic language, which I admit YMMV since dynamic languages don't have a clearly defined set of mandatory features, but have a look at C++:

Dynamic typing? No
Can alter shit at runtime? No
Introspection? No
Macros? Hardly
Eval? No
Closures? No
Anonymous functions? No
First-class functions? Very limited

So no. Compare with Python:

Dynamic typing? Yes
Can alter shit at rutime? Yes
Introspection? Yes
Macros? No
Eval? Yes
Closures? Yes
Anonymous functions? Yes
First-class functions? Yes

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