From 32c9fbfab16432e494fa773137b90b9cfb6b084c Mon Sep 17 00:00:00 2001 From: JYJSXX Date: Mon, 2 Sep 2024 01:22:11 +0800 Subject: [PATCH] final version --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 2 +- src/main.cpp | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84a27fa..7386a5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(stl_debug VERSION 0.1.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) +set(default_build_type "Debug") + INCLUDE_DIRECTORIES( include ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 802fad6..722da09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable( - stl_test main.cpp Human.cpp Student.cpp logging.cpp + lab0_debug main.cpp Human.cpp Student.cpp logging.cpp ) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 898c438..14e5a6c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include "Human.hpp" #include "Student.hpp" @@ -11,7 +13,11 @@ class check{ } }; -int main(int, char**){ +int main(int argc, char** argv){ + if(argc == 1 || std::string(argv[1]) != "-t"){ + std::cerr << "error: invalid argument\n"; + exit(-1); + } printf("Hello, from stl_debug!\n"); std::vector vec; Human human(25, "John Doe"); @@ -21,9 +27,17 @@ int main(int, char**){ for (const auto& h : vec) { std::cout << h->print(); } + // auto student1 = new Student(); //TODO: Error 1 : why? auto student1 = static_cast(vec.back()); - // check check1 = check(student); + // check check1 = check(student); //TODO: Error 2 : why? check check1 = check(student1); - LOG(DEBUG) << student1->print(); - LOG(WARNING) << human.print(); + // LOG(DEBUG) << student1->print(); + // LOG(WARNING) << human.print(); + + // std::list list; + // list.push_back(1); + // for(auto i: list){ + // list.remove(i); + // } + return 0; } -- GitLab