main.cpp 1.14 KB
Newer Older
刘睿博's avatar
刘睿博 committed
1
#include <iostream>
刘睿博's avatar
刘睿博 committed
2
#include <list>
刘睿博's avatar
刘睿博 committed
3
#include <string>
刘睿博's avatar
ver 1.0  
刘睿博 committed
4 5 6
#include <stdio.h>
#include "Human.hpp"
#include "Student.hpp"
刘睿博's avatar
刘睿博 committed
7
#include "logging.hpp"
刘睿博's avatar
ver 1.0  
刘睿博 committed
8 9
#include <vector>

刘睿博's avatar
ver 1.1  
刘睿博 committed
10 11 12 13 14 15 16
class check{
    public:
    explicit check(Student* student){
        printf("Student object created\n");
    }
};

刘睿博's avatar
刘睿博 committed
17 18 19 20 21
int main(int argc, char** argv){
    if(argc == 1 || std::string(argv[1]) != "-t"){
        std::cerr << "error: invalid argument\n";
        exit(-1);
    }
刘睿博's avatar
ver 1.0  
刘睿博 committed
22 23 24 25 26 27 28
    printf("Hello, from stl_debug!\n");
    std::vector<Human*> vec;
    Human human(25, "John Doe");
    Student student(20, "Jane Doe", "MIT");
    vec.push_back(&human);
    vec.push_back(&student);
    for (const auto& h : vec) {
刘睿博's avatar
刘睿博 committed
29
        std::cout << h->print();
刘睿博's avatar
ver 1.0  
刘睿博 committed
30
    }
刘睿博's avatar
刘睿博 committed
31
    // auto student1 = new Student();   //TODO: Error 1 : why?
刘睿博's avatar
ver 1.1  
刘睿博 committed
32
    auto student1 = static_cast<Student*>(vec.back());
刘睿博's avatar
刘睿博 committed
33
    // check check1 = check(student);   //TODO: Error 2 : why?
刘睿博's avatar
ver 1.1  
刘睿博 committed
34
    check check1 = check(student1);
刘睿博's avatar
刘睿博 committed
35 36 37 38 39 40
    // LOG(DEBUG) << student1->print();
    // LOG(WARNING) << human.print();

    // std::list<int> list;
    // list.push_back(1);
    // for(auto i: list){
刘睿博's avatar
刘睿博 committed
41
    //     list.remove(i);              //TODO: Error 3 : why?
刘睿博's avatar
刘睿博 committed
42 43
    // }
    return 0;
刘睿博's avatar
ver 1.0  
刘睿博 committed
44
}