public.cpp

来自「《C C++程序员实用大全》配套光盘源代码 欢迎下载」· C++ 代码 · 共 36 行

CPP
36
字号
#include <iostream.h>
#include <string.h>

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);
 }

void main(void)
 {
   movie fugitive, sleepless;

   fugitive.initialize("The Fugitive", "Harrison Ford", "Tommy Lee Jones");
   sleepless.initialize("Sleepless in Seattle", "Tom Hanks", "Meg Ryan");
   cout << "The last two movies I've watched are: " << fugitive.name << " and " << sleepless.name << endl;
   cout << "I thought " << fugitive.first_star << " was great!" << endl;
 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?