Guest User

Untitled

a guest
Jun 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Tutorial Week 4 (02/01/12)
  2.  
  3. --what does #include do?
  4. --to access the files included, like the codes inside them.
  5. --copy and paste files included into ur files
  6.  
  7. --difference b/t <...> and "..."
  8. --<...> extended libraries, can be found in linux.
  9. --"..." look through the current directory.
  10.  
  11. --why to include headers?
  12. --similar to "provide" in scheme.
  13.  
  14. --Assignment 3
  15. --g++ -c my-func.cpp
  16. --.c allows you to compile
  17. --.o not ready to be compile yet
  18. --g++ main.cpp my-func.o -o solution
  19. --
  20.  
  21. --multiple functions with the same names?
  22. --
  23.  
  24. --#include <cassert> (in c++)----in c, "assert.h"
  25. #include <cstdlib> (in c++) ----in c, "stdlib.h"
  26.  
  27. why to use assert? --
  28.  
  29. --input -- cin
  30. -- cout << i << "Hello"; ok to do that;
  31. --cin >> i >> n; <=> cin >> i; cin >> n;
  32. --each cin will not include whitespace, but will at a whitespace;
  33.  
  34.  
  35. --strings
  36. --in c++, a string is an object;
  37. in c, A character array terminated with a null character '\0';
  38. --std::string?
  39. --int a;
  40. int main () {
  41. int a;
  42. ::a = 7; //:: assign 7 to the global a;
  43. }
  44.  
  45. --int a;
  46. int main () {
  47. struct b {
  48. ...
  49. int a; };
  50. b::a=7; //assign 7 to the a inside b;
  51. }
  52.  
  53. --use :: operator in header files;
  54. --use 'using namespace std' only in main.cpp files, not headers
  55. --in general, use std:: when not using namespace;
  56.  
  57. --command line arguments:
  58. --int main (int argv, char* argc[])
  59. --argv: number of arguments, including command name
  60. --argc: array of pointers to character strings(C strings)
  61.  
  62. --How to create the previous program
  63. --instead of using cin for input, use command line arguments
  64. string s; // s = hi
  65. s = argc[0];
  66. string s(argc[0])
Add Comment
Please, Sign In to add comment