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
There was some discussion some time ago. One of the conclusions was that you could omit the constint 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.