Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shape.h -- this would be A.dll
- #pragma once
- // Notice the conditional
- #ifdef SHAPE_EXPORTS
- #define SHAPE_API __declspec(dllexport)
- #else
- #define SHAPE_API __declspec(dllimport)
- #endif
- class SHAPE_API Shape /*: public IShape*/
- {
- public:
- Shape();
- Shape(int sides, int sideLength, int apothem);
- ~Shape();
- int Perimeter();
- double Area();
- private:
- int sides;
- int sideLength;
- int apothem;
- };
- // Shape.cpp
- // Do it before including the header to get dllexport
- #define SHAPE_EXPORTS
- #include "stdafx.h"
- #include "Shape.h"
- Shape::Shape() : sides(0), sideLength(0), apothem(0)
- {
- }
- Shape::Shape(int sides, int sideLength, int apothem) : sides(sides), sideLength(sideLength), apothem(apothem)
- {
- }
- Shape::~Shape()
- {
- }
- double Shape::Area()
- {
- if (sides == 1 || sides == 2)
- {
- return -1;
- }
- return .5 * Perimeter() * apothem;
- }
- int Shape::Perimeter()
- {
- return sideLength * sides;
- }
- // ShapesTester.h - this would be B.dll
- #include "../TestHarness/ITest.h"
- class ShapesTester : ITest
- {
- public:
- ShapesTester();
- ~ShapesTester();
- bool Test() override;
- ShapesTester & ShapesTesterFactory();
- private:
- };
- // ShapesTester.cpp
- #include "stdafx.h"
- #include "ShapesTester.h"
- #include "Shape.h"
- ShapesTester::ShapesTester()
- {
- }
- ShapesTester::~ShapesTester()
- {
- }
- bool ShapesTester::Test()
- {
- Shape myShape = Shape(3, 9, 5); // error here; Cannot resolve symbol 'Shape'
- return myShape.Area() == 67.5;
- }
- ShapesTester & ShapesTesterFactory()
- {
- ShapesTester * tester = new ShapesTester();
- return *tester;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement