Thanks for the reply.
Ok, I may use strings. But I want to know how to do that with character type. Now, see, If I use char*, like
Code:
class Colors
{
private:
int code;
char* color;
public:
Colors()
{
code=0;
color=NULL;
}
void setCd(int cd)
{ code = cd; }
int getCd()
{ return code; }
void setCl(char* cl)
{ color = cl; }
char* getCl()
{ return color; }
void input()
{
int cod=0; char clr[25];
cout << "Code: "; cin >> cod;
cout << "Color: "; cin >> clr;
setCd(cod); setCl(clr);
}
~Colors()
{ }
};
And try to run the program as..
Code:
int main()
{
Colors c1, c2;
cout << "Object1\n";
c1.input();
cout << "\n\nObject2\n";
c2.input();
cout << "\nColor Code for Object1: " << c1.getCd() ;
cout << "\nColor for Object1: " << c1.getCl() ;
cout << "\nColor Code for Object2: " << c2.getCd() ;
cout << "\nColor for Object2: " << c2.getCl() ;
getch();
return 0;
}
It don't return the exact values for COLORS as input by the user. That's why I was looking for array, if it may return the exact one, but couldn't do properly.