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

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

刘睿博's avatar
刘睿博 committed
16 17 18 19 20
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
21 22 23 24 25 26 27
    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
28
        std::cout << h->print();
刘睿博's avatar
ver 1.0  
刘睿博 committed
29
    }
刘睿博's avatar
刘睿博 committed
30
    // auto student1 = new Student();   //TODO: Error 1 : why?
刘睿博's avatar
ver 1.1  
刘睿博 committed
31
    auto student1 = static_cast<Student*>(vec.back());
刘睿博's avatar
刘睿博 committed
32
    // check check1 = check(student);   //TODO: Error 2 : why?
刘睿博's avatar
ver 1.1  
刘睿博 committed
33
    check check1 = check(student1);
刘睿博's avatar
刘睿博 committed
34 35 36 37 38 39 40 41 42
    // LOG(DEBUG) << student1->print();
    // LOG(WARNING) << human.print();

    // std::list<int> list;
    // list.push_back(1);
    // for(auto i: list){
    //     list.remove(i);
    // }
    return 0;
刘睿博's avatar
ver 1.0  
刘睿博 committed
43
}