can.cpp

来自「c++最经典的入门书籍」· C++ 代码 · 共 19 行

CPP
19
字号
// Can.cpp
#include "Can.h"
#include <iostream>

Can::Can(double canDiameter, double canHeight) :
                                  diameter(canDiameter), height(canHeight) {}

                                  // Function to calculate the volume of a Can object
double Can::volume() const {
  return pi * diameter * diameter * height / 4;
}

Can::~Can() {
  std::cout << "Can destructor" << std::endl;
}

// Definitions for the Can class
const double Can::pi = 3.14159265;                  // Initialize static member

⌨️ 快捷键说明

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