1stclass.cpp

来自「不错书对C++/C程序员很有用的大家不要错过.」· C++ 代码 · 共 28 行

CPP
28
字号
#include <iostream.h>
#include <iomanip.h>
#include <string.h>

class Book 
{
  public: 
    char title[256];
    char author[64];
    float price;
    void show_title(void) { cout << title << '\n'; };
    float get_price(void) { return(price); };
};

void main(void)
 {
   Book tips; 
  
   strcpy(tips.title, "Jamsa's C/C++ Programmer's Bible");
   strcpy(tips.author, "Jamsa and Klander");
   tips.price = 49.95;

   tips.show_title();
   cout << "The book's price is " << setprecision(2) << 
     tips.get_price();
 }

⌨️ 快捷键说明

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