Hi everyone,
I recently got an assignment that requires me to use a class and strings to make a program about a movie. The exact question is...
"Define a class named Movie. Include private fields for the title, year, and name of the director. Include three public functions with the prototypes void Movie::setTitle(string); , void Movie::setYear(int); , and void setDirector(string); . Include another function that displays all the information about a Movie. Write a main() function that declares a movie object named myFavoriteMovie . Set and display the object’s fields."
... So far, all i have is below and i am having trouble with the strcpy function. I get the error message "error C2664: 'char*strcpy(char*,const char*)': cannot convert argument 1 from 'std::string' to 'char*' "...
Here is my code, let me know what you think.
Thanks!
strcpy is when you're using old-fashioned C-style strings, i.e. char arrays.
You're using the C++ std::string class for strings, so you don't need to use strcpy. That's the reason for your error - you're trying to pass a std::string, when strcpy expects a char array.