-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
34 lines (25 loc) · 885 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "dlclass.hpp"
#include "polygon.hpp"
#include <iostream>
#include <memory>
int main(void) {
auto dlTriangle = new DLClass<Polygon>("./triangle.so");
auto dlSquare = new DLClass<Polygon>("./square.so");
int x = 5;
std::shared_ptr<Polygon> triangle = dlTriangle->make_obj(3);
std::shared_ptr<Polygon> square = dlSquare->make_obj(x);
delete dlTriangle;
delete dlSquare;
if(!triangle) {
std::cerr << "Failed to instantiate a triangle." << std::endl;
return 1;
}
std::cout << "Triangle area: " << triangle->area() << std::endl;
triangle = std::shared_ptr<Polygon>(NULL);
if(!square) {
std::cerr << "Failed to instantiate a triangle." << std::endl;
return 1;
}
std::cout << "Square area: " << square->area() << std::endl;
square = std::shared_ptr<Polygon>(NULL);
}