Fourteen98

To Prisci

Sep 28th, 2021
886
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.   string str = "Priscilla"; //
  9.  
  10.   rotate(str.begin(), str.begin() + 3, str.end());
  11.   cout <<str;
  12.  
  13.  
  14.  
  15.   return 0;
  16. }
  17.  
  18.  
  19.  
  20. /// Another one
  21.  
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int add(int , int );
  26.  
  27.  
  28.  
  29. int main() {
  30.  
  31.   int(*funcPtr)(int, int);
  32.  
  33.   funcPtr  = add;
  34.  
  35.   cout << "original function sum: "  << add(5, 5) <<endl;
  36.   cout << "pointer function sum: " << funcPtr(2,2);
  37.  
  38.  
  39.   return 0;
  40. }
  41.  
  42.  
  43.  
  44. int add(int a, int b){
  45.  
  46.   return a+b;
  47. }
  48.  
  49.  
  50. // Another one
  51.  
  52. #include <iostream>
  53. using namespace std;
  54.  
  55.  
  56.  
  57. int main() {
  58.   // <type of pointer> *const <name of pointer
  59.   int firstnumber = 1;
  60.   int secondnumber = 2;
  61.   int thirdnumber = 3;
  62.  
  63.  
  64.   // a pointer const
  65.   const int *ptr = &firstnumber;
  66.   *ptr = 400; // here you cannot change the value the pointer refe
  67.   ptr = &secondnumber;
  68.  
  69.  
  70.   // a normal pointer
  71.   int *temp = &secondnumber;
  72.   *temp = 700;  // here you can change the value the pointer refe
  73.  
  74.  
  75.   // const pointer to a const
  76.   const int* const tpr = &thirdnumber;
  77.   *tpr = 400;
  78.   *tpr = &firstnumber;
  79.  
  80.  
  81.   /*
  82.     auto_ptr
  83.     unique_ptr
  84.     shared_ptr
  85.     weak_ptr
  86.   */
  87.  
  88.   return 0;
  89. }
RAW Paste Data