Modern C++ Course [Lecture 0] {Course Introduction and Hello World} & [Lecture 1] {Variables, Basic Types, Control Structures}

http://www.ipb.uni-bonn.de/teaching/modern-cpp/

 

Introduction: This page contains all the information on the course Modern C++ for Computer Vision and Image Processing including all lecture videos (also available on YouTube), lecture slides, and the homework assignments.

 


 

 

2018/12/25

 

Lecture_0: Course Introduction and Hello World

 

 

 

 

 https://google.github.io/styleguide/cppguide.html

 

 

 

 

 

 

Microsoft Visual c++ compiler is exclusive in Windows.

Here we prefer Clang, because Clang has better error explanation.

 

 


 

Lecture_1: Variables, Basic Types, Control Structures 

 

  

 

Google naming rules: https://google.github.io/styleguide/cppguide.html#General_Naming_Rules 

 

 

 

auto is a new and reliable feature in c++ 11.

 

[Advanced] If curious read detailed info here: http://en.cppreference.com/w/cpp/language/types 

 

float numbers are imprecise, so dont do "==" operation.

eg. (float) ??? == 2 turns into false, because ??? = 1.99999999999

 

 

 

 

 

 

 

No project has no Vector!

 

 

 emplace_back is computationally expensive, because of the resizing.

Use a reserve(n) to accelerate the program if you know roughly how many items are going to be.

 

 

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){

    vector<int> int_vec = {1,2};
    cout << int_vec.front() << " " << int_vec.back() << endl;
    int_vec.emplace_back(3);
    cout << int_vec[0] << " " << int_vec[int_vec.size()-1] << endl;

    vector<string> str_vec = {"hello","world"};
    cout << str_vec.front() << " " << str_vec.back() << endl;

    return 0;
}

  

 

show all the warnings.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 we prefer "if" to "while"

 

 

 

 

 

three steps:

 

add - commit - push 

 

 

 

 References

Cpp Core Guidelines: https://github.com/isocpp/CppCoreGuidelines

Google Code Styleguide: https://google.github.io/styleguide/cppguide.html // kind of goes into depth

Git guide: http://rogerdudler.github.io/git-guide/

C++ Tutorial: http://www.cplusplus.com/doc/tutorial/

Book: Code Complete 2 by Steve McConnell // if you feel programming is what you like, this is a book you must read in your career. And why not doing it kind of now? 

 

posted @ 2018-12-26 12:19  ecoflex  阅读(249)  评论(0编辑  收藏  举报