Compare commits

...

10 Commits

@ -0,0 +1,37 @@
#ifndef CIRCLE_H
#define CIRCLE_H
#include <iostream>
using namespace std;
#define PI 3.14
class Circle
{
private:
double r;//半径
public:
Circle();//构造函数
Circle(double R);//构造函数
double Area();//求面积函数
};
Circle::Circle()
{
this->r=5.0;
}
Circle::Circle(double R)
{
this->r=R;
}
double Circle::Area()
{
return PI*r*r;
}
#endif

@ -1,9 +1,15 @@
#include <iostream>
#include "atlas.h"
#include "worka.h"
#include "workb.h"
#include "Circle.h"
using namespace std;
int main() {
atlasPrint();
MyClass().Print();
test().Print();
cout << Circle().Area() << endl;
return 0;
}

@ -0,0 +1,41 @@
#ifndef WORKA_H
#define WORKA_H
#include <string>
#include <iostream>
using namespace std;
class MyClass
{
private:
string id; //id
int age;
string phone;
public:
MyClass() { //构造函数
id = string("empty id");
age = 20;
phone = string("13684598216");
}
MyClass(string id, int age, string phone) { //构造函数
this->id = id;
this->age = age;
this->phone = phone;
}
~MyClass() { //析构函数
}
void Print() { //输出函数
cout << "id是";
cout << id << endl;
cout << "age是";
cout << age << endl;
cout << "phone是";
cout << phone << endl;
}
};
#endif

@ -0,0 +1,41 @@
#ifndef WORKB_H
#define WORKB_H
#include <string>
#include <iostream>
using namespace std;
class test
{
private:
string id; //id
int age;
string phone;
public:
test() { //构造函数
id = string("empty id");
age = 21;
phone = string("15185626392");
}
test(string id, int age, string phone) { //构造函数
this->id = id;
this->age = age;
this->phone = phone;
}
~test() { //析构函数
}
void Print() { //输出函数
cout << "id是";
cout << id << endl;
cout << "age是";
cout << age << endl;
cout << "phone是";
cout << phone << endl;
}
};
#endif
Loading…
Cancel
Save