Commit 32c9fbfa authored by 刘睿博's avatar 刘睿博 🎯

final version

parent 623e0770
...@@ -3,6 +3,8 @@ project(stl_debug VERSION 0.1.0 LANGUAGES C CXX) ...@@ -3,6 +3,8 @@ project(stl_debug VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(default_build_type "Debug")
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
include include
) )
......
add_executable( 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
#include <iostream>
#include <string>
#include <stdio.h> #include <stdio.h>
#include "Human.hpp" #include "Human.hpp"
#include "Student.hpp" #include "Student.hpp"
...@@ -11,7 +13,11 @@ class check{ ...@@ -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"); printf("Hello, from stl_debug!\n");
std::vector<Human*> vec; std::vector<Human*> vec;
Human human(25, "John Doe"); Human human(25, "John Doe");
...@@ -21,9 +27,17 @@ int main(int, char**){ ...@@ -21,9 +27,17 @@ int main(int, char**){
for (const auto& h : vec) { for (const auto& h : vec) {
std::cout << h->print(); std::cout << h->print();
} }
// auto student1 = new Student(); //TODO: Error 1 : why?
auto student1 = static_cast<Student*>(vec.back()); auto student1 = static_cast<Student*>(vec.back());
// check check1 = check(student); // check check1 = check(student); //TODO: Error 2 : why?
check check1 = check(student1); check check1 = check(student1);
LOG(DEBUG) << student1->print(); // LOG(DEBUG) << student1->print();
LOG(WARNING) << human.print(); // LOG(WARNING) << human.print();
// std::list<int> list;
// list.push_back(1);
// for(auto i: list){
// list.remove(i);
// }
return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment