Slide 2.9 Introduction to QtCreator. Can show creating a new project, advertise Qt as a cross platform frame- work (with many extension to c++), mobile android/ios... games+applications. /* * hello.cpp * This program prints a welcome message * to the user. */ #include int main() { std::cout << "Hello, world!" << std::endl; return 0; } ---------------------------------------------------------------------- Slide 2.11: Show the effect of return value (from terminal with $?) ---------------------------------------------------------------------- Slide 2.14: Size of fundamental types on this machine. ---------------------------------------------------------------------- Slide 2.16: /* * main.cpp * This program introduces pointers and references. */ #include int main() { int a[100]; int* p= a; a[0]=12; std::cout << a[0] << " " << p[0] << std::endl; return 0; } ---------------------------------------------------------------------- Slide 2.16: Do some pointer arithmetic with p (set some more value in a); ---------------------------------------------------------------------- Slide 2.17: show the similitude between “ int* const” and “int&”. // int b = 10; // int& r; // int& r=b; // std::cout << "r= " << r << ", b=" << b << ", p=" << p << std::endl; // b = 12; // std::cout << "r= " << r << ", b=" << b << ", p=" << p << std::endl; ---------------------------------------------------------------------- Slide 1.36: show “using namespace std;”. ---------------------------------------------------------------------- Slide 2.31: Show returning more than two values void minmax (int a, int b, int& min, int& max) { ... } Large object struct t { int a[100]; }; void this_does_copy(t v) { std::cout << v.a << std::endl; } void this_does_not_copy(t& v) { std::cout << v.a << std::endl; } intmain(int argc, char ∗∗argv) { tt1; std::cout << t1.a << std::endl; this_does_copy(t1); this_does_not_copy(t1); } ---------------------------------------------------------------------- Slide 1.43: Show the compilation error void grow (const int& age) { age = age + 1 ; } int main ( ) { int age = 20 ; grow(age) ; return 0 ; } ---------------------------------------------------------------------- ---------------------------------------------------------------------- Slide2.35 Show some string comparisons: strings1= ”apa”; strings2= ”apa”; std::cout << (s1 > s2) << std::endl; s1= ”apaw”; s2= ”apa”; std::cout << (s1 > s2) << std::endl; s1 = ”apaw”; s2 = ”apb”; std::cout << (s1 > s2) << std::endl; std::cout << (”apaw” > ”apa”) << std::endl; ---------------------------------------------------------------------- Slide2.35 const char* cstring= ”apa”; std::string cppstring= cstring; const char* othercstring= cppstring.cstr(); ---------------------------------------------------------------------- Slide2.37 void printDouble(strings){ cout << s*2 << endl; } voidappendFour(intn){ cout << n+”4” << endl; } int main(){ appendFour(2); } Then in appendFour replace “4” by “1234” ---------------------------------------------------------------------- Slide2.41 string name; cout << ”Typeyourname:”; cin >> name; cout << ”Hello,” << name << endl; Replace cin with “getline(cin,name);”