diff --git a/ccv/sheet1/CMakeLists.txt b/ccv/sheet1/CMakeLists.txt index e69de29..fa2d69a 100644 --- a/ccv/sheet1/CMakeLists.txt +++ b/ccv/sheet1/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +add_library(Rectangle Rectangle.cpp) +project(sheet1) +add_executable(main main.cpp) +target_link_libraries(main Rectangle) +add_executable(hello hello.cpp) +add_executable(AskInteger AskInteger.cpp) diff --git a/ccv/sheet1/Rectangle.cpp b/ccv/sheet1/Rectangle.cpp index 7d30a0c..0349cc6 100644 --- a/ccv/sheet1/Rectangle.cpp +++ b/ccv/sheet1/Rectangle.cpp @@ -2,29 +2,16 @@ // Created by jim on 4/4/17. // #include +#include "Rectangle.h" using namespace std; -class Rectangle +Rectangle::Rectangle(unsigned int width, unsigned int height) { -private: - unsigned int width; - unsigned int height; - -public: - Rectangle(unsigned int width, unsigned int height) - { - this->width = width; - this->height = height; - } - - unsigned int area() - { - return this->height * this->width; - } -}; - -int main() -{ - Rectangle* rec = new Rectangle(10, 20); - cout << rec->area() << endl; + this->width = width; + this->height = height; +} + +unsigned int Rectangle::area() +{ + cout << this->width * this->height << endl; } diff --git a/ccv/sheet1/Rectangle.h b/ccv/sheet1/Rectangle.h new file mode 100644 index 0000000..c2eb999 --- /dev/null +++ b/ccv/sheet1/Rectangle.h @@ -0,0 +1,19 @@ +// +// Created by jim on 4/4/17. +// + +#ifndef SHEET1_RECTANGLE_H +#define SHEET1_RECTANGLE_H + +class Rectangle +{ +private: + unsigned int width; + unsigned int height; + +public: + Rectangle(unsigned int, unsigned int); + unsigned int area(); +}; + +#endif //SHEET1_RECTANGLE_H diff --git a/ccv/sheet1/main.cpp b/ccv/sheet1/main.cpp new file mode 100644 index 0000000..d7219c2 --- /dev/null +++ b/ccv/sheet1/main.cpp @@ -0,0 +1,11 @@ +// +// Created by jim on 4/4/17. +// +#include "Rectangle.h" + +int main() +{ + Rectangle* rec = new Rectangle(20, 10); + rec->area(); + return 0; +}