Hi guys,
quick question, just wandering is it possible to define a const array of anything as a data member of a class?
Below is an example of what I mean (THis code does not compile by the way!)
quick question, just wandering is it possible to define a const array of anything as a data member of a class?
Below is an example of what I mean (THis code does not compile by the way!)
Rich (BB code):
#include <iostream>
using namespace std;
class test
{
public:
test();
void output();
private:
const char A[2] = {'h','d'};
};
test::test()
{
//do nothing
}
void test::output()
{
cout << A[0];
cout << A[1];
}
int main()
{
test test1;
test1.output();
}