Skip to content

Commit 29161a4

Browse files
ladisginkorifey
authored andcommitted
update cpp example, small fix for c++
1 parent 3f4c8a3 commit 29161a4

File tree

18 files changed

+20
-232
lines changed

18 files changed

+20
-232
lines changed

integration-tests/cpp-example/Refs.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

integration-tests/cpp-example/Refs.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

integration-tests/cpp-example/SimpleClass.cpp

Lines changed: 0 additions & 38 deletions
This file was deleted.

integration-tests/cpp-example/SimpleClass.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

integration-tests/cpp-example/VirtualMethods.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

integration-tests/cpp-example/VirtualMethods.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

integration-tests/cpp-example/build.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

integration-tests/cpp-example/cxx_lib/point_2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Point_2d operator-(Point_2d lhs, const Point_2d& rhs) {
5151
}
5252

5353

54-
double get_dist(const Point_2d& lhs, Point_2d& rhs) {
54+
double get_dist(const Point_2d& lhs, const Point_2d& rhs) {
5555
auto t = lhs - rhs;
5656
return t.get_dist_to_zero();
5757
}

integration-tests/cpp-example/cxx_lib/point_2d.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#define POINT_2D_HPP
77

88
class Point_2d {
9-
public:
9+
private:
1010
int x;
11+
public:
1112
int y;
1213

1314
Point_2d();
@@ -24,12 +25,15 @@ class Point_2d {
2425
friend Point_2d operator-(Point_2d lhs, const Point_2d& rhs);
2526

2627
double get_dist_to_zero() const;
28+
friend double get_dist(const Point_2d& lhs, const Point_2d& rhs);
29+
friend void set_to_zero(Point_2d& point);
30+
friend void set_abs_by_ref(Point_2d& point);
2731
};
2832

2933
Point_2d operator+(const Point_2d& lhs, const Point_2d& rhs);
3034
Point_2d operator-(Point_2d lhs, const Point_2d& rhs);
3135

32-
double get_dist(const Point_2d& lhs, Point_2d& rhs);
36+
double get_dist(const Point_2d& lhs, const Point_2d& rhs);
3337

3438
void set_to_zero(Point_2d& point);
3539

integration-tests/cpp-example/cxx_lib/triangle.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
33
*/
44

5-
#include "triangle.hpp"
5+
#include "triangle.h"
6+
#include "point_2d.hpp"
67
#include <cmath>
78

89

@@ -35,9 +36,9 @@ double Triangle::get_perimeter() {
3536
}
3637

3738
double Triangle::get_area() {
38-
auto side1 = get_dist(vertex[0], vertex[1]);
39-
auto side2 = get_dist(vertex[1], vertex[2]);
40-
auto side3 = get_dist(vertex[2], vertex[0]);
39+
double side1 = get_dist(vertex[0], vertex[1]);
40+
double side2 = get_dist(vertex[1], vertex[2]);
41+
double side3 = get_dist(vertex[2], vertex[0]);
4142
auto p = this->get_perimeter();
4243
return sqrt(p * (p - side1) * (p - side2) * (p - side3));
4344
}

0 commit comments

Comments
 (0)