Mega Code Archive

 
Categories / C++ / Class
 

Class with only public fields and methods

#include <iostream> #include <string.h> using namespace std; class movie {    public:      char name[64];      char first_star[64];      char second_star[64];       void show_movie(void);      void initialize(char *name, char *first, char *second); }; void movie::show_movie(void) {    cout << "Movie name: " << name << endl;    cout << "Starring: " << first_star << " and " << second_star << endl << endl; } void movie::initialize(char *movie_name, char *first, char *second) {    strcpy(name, movie_name);    strcpy(first_star, first);    strcpy(second_star, second); } int main(void) {    movie fugitive, sleepless;    fugitive.initialize("A", "F", "B");    sleepless.initialize("C", "D", "E");    cout << fugitive.name << " and " << sleepless.name << endl;    cout << fugitive.first_star << endl; }