C style char arrays

If I read in characters into a char array using cin, why do I need a constructor for the char array?
There is no such thing as a constructor for any C-style array of any type.
I thought a constructor in C++ initializes a char array?
POD types, structs, and classes (can) have constructors. Arrays cannot.

(POD types are "Plain 'Ol Data" types like int, double, char, bool and all other integer/floating point types.)

I have a class called stringcreator. A constructor in that class is defined as
stringcreater ( const char different[] ). The constructor's job is to construct an array to hold a charater string.

However, I want any string to be inputted by a user of the program. Hence I'm using the following in main()

char str[256];
cout << "Enter a string: " << endl;
cin >> str;

Why then do I need the constructor above? Hope this clear now.
Constructors are meant to do some primary initialization for the class that it's part of, not anything it's not part of. In this case, you don't need a constructor.
@compone87:

I think the confusion is over your phrasing.

You have a constructor for stringcreator that initializes the char array (either to an empty string
or copies the string passed into the constructor, I would guess).

Topic archived. No new replies allowed.