static in class

Hi guys,
I have question in my Convert class,my code as below:
#ifndef _CONVERT_
#define _CONVERT_

#include <iostream>

using namespace std;
class Convert {
public:
Convert(const int n, const int num) {
nByte(n, num);
reverse();
}
void display()const { cout << rel << endl; }
void getResult(string &result)const {result = rel;}

private:
void nByte(const int n, const int num);
void reverse();

private:
string rel;
static const int nn = 10;//It's good
static const string list = "0123456789abcdef";//here is bad why?
};
const int Convert::nn;
const string Convert::list;
#endif
You just can't intialize non-static const integral values in class like that. As for an actual "why", I don't remember if there was even a reason.
Thank you firedraco!
I can't find the explain on C++ primer,So its just can't but we don't know why?
Well, we know why: Cause it's defined like that. There is probably some obscure technical reason for this, but for now it's just because.
There isn't a real technical reason, C++0x will allow in-class initialization of any data member
There was some discussion some time ago. One of the conclusions was that you could omit the const int Convert::nn; definition, as long as you don't take the address of nn, because you need only declaration in most cases, but definition when you need pointers. I didn't get it, but I thought it was interesting line of argument. I don't know if that is true, and whether it generalizes in any significant way.
Topic archived. No new replies allowed.