Monday, March 31, 2008

Template static member brace-enclosed initializer

Or something...

#include <iostream>

using namespace std;

template<class _prec=double>
class myclass {
public:
static const string mystuff[];

_prec avalue;
};

template<class _prec>
const string myclass<_prec>::mystuff[] = {"Athing", "Another","Things"};

int main() {

myclass<> m;

cout << m.mystuff[0] << endl;
}

3 comments:

Niall Haslam said...

wtf does that end up printing.

new said...

Athing, for some reason I had trouble getting this working not sure why looking at it there's nothing weird but I wanted to log it somewhere...

Screen Doors Houston said...

This is ggreat