ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
// const - keyword to let compiler know that something imutable// static - depends on the context; // static variables retain their value between function calls // static functions belong to a class, and can be called without an instance/object.#include using namespace std;class Triangle{ private: double base; double height; public: Triangle() { base = 1; height = 1; } Triangle(double b, double h) { base = b; height = h; } double getBase() const { return base; } double getHeight() const { return height; } double getArea() { double area = (base * height) / 2; return area; } static double getArea(double b, double h) { double area = (b * h) / 2; return area; }};int main(){ cout
// const - keyword to let compiler know that something imutable
// static - depends on the context;
// static variables retain their value between function calls
// static functions belong to a class, and can be called without an instance/object.
#include
using namespace std;
class Triangle
{
private:
double base;
double height;
public:
Triangle()
{
base = 1;
height = 1;
}
Triangle(double b, double h)
{
base = b;
height = h;
}
double getBase() const {
return base;
}
double getHeight() const {
return height;
}
double getArea() {
double area = (base * height) / 2;
return area;
}
static double getArea(double b, double h) {
double area = (b * h) / 2;
return area;
}
};
int main()
{
cout