upload work 2022-03-11

main
lensfrex 3 years ago
parent 8d950d0cd4
commit fc7e4dd1d1
Signed by: lensfrex
GPG Key ID: 947ADABD8533C476
  1. 79
      20200311.cpp
  2. 3
      CPP-Learning.md

@ -0,0 +1,79 @@
#include "iostream"
using namespace std;
class Circle {
public:
Circle(int r);
Circle();
const double PI = 3.1415926;
double getLength();
double getArea();
double getRadius();
private:
double radius = 0;
};
double Circle::getLength() {
return radius * 2 * PI;
}
double Circle::getArea() {
return radius * radius * PI;
}
double Circle::getRadius() {
return radius;
}
Circle::Circle(int r) : radius(r) {}
Circle::Circle() : radius(0) {}
int main() {
Circle circle(17);
cout << "Area | Length | Radius" << endl;
cout << circle.getArea() << endl << circle.getLength() << endl << circle.getRadius();
}
// --------------------------------------------------------------
class Circle2 {
public:
const double PI = 3.1415926;
void printArea();
void printLength();
void printRadius();
Circle2(double radius) : radius(radius) {
area = radius * radius * PI;
length = radius * 2 * PI;
}
Circle2(const Circle2 &c2) {
radius = c2.radius;
length = c2.length;
area = c2.area;
}
private:
double radius = 0;
double length = 0;
double area = 0;
};
void Circle2::printArea() {
cout << "Area: " << area << endl;
}
void Circle2::printLength() {
cout << "Length: " << length << endl;
}
void Circle2::printRadius() {
cout << "Radius: " << radius << endl;
}

@ -0,0 +1,3 @@
# CPP-Learning
Loading…
Cancel
Save