error using c++ arry of chars in OOP

#include<iostream.h>


class linginUloMo {

private:

char haha[] = {'A','B','C','D','E','F','G','H','I','J','K','L'};
char hehe[] = {'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};


public:

void msg1(void) {
cout<<"The designer and original implementer of C++ is ";
}

void msg2(void) {
cout<<haha[1]<<haha[9]<<haha[0]<<hehe[5]<<hehe[1]<<haha[4]<<" ";
cout<<hehe[6]<<hehe[7]<<hehe[5]<<hehe[2]<<hehe[8]<<hehe[6];
cout<<hehe[7]<<hehe[5]<<hehe[8]<<hehe[3]<<endl;
}

};


int main(void) {

linginUloMo go;

go.msg1();
go.msg2();

return 0;
}


// this doesn't work, but if i'll do this prog without classes, it work perfectly fine. plz help.
Last edited on
You should post actual errors as well. I think the reason is that you can't define those arrays inline in the class like that; only static integral types are allowed to work that way.

EDIT: And this shouldn't be in the Lounge.
Last edited on
Try using a default constructor to set up your character arrays.

Just in case you're not sure how, on the following page, scroll down until you see Default Constructor.
http://cplusplus.com/doc/tutorial/classes/

EDIT: Indeed, this shouldn't be in the lounge.

-Albatross
Last edited on
thanks, sorry if I posted it at the lounge, I'm new to this website. thanks again.
Topic archived. No new replies allowed.