Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int* createInt()
- {
- int* ptr{ nullptr };
- ptr = new int{42};
- std::cout << "ptr = " << ptr << " *ptr = " << *ptr << '\n';
- *ptr = 38;
- std::cout << "ptr = " << ptr << " *ptr = " << *ptr << '\n';
- return ptr;
- }
- int main()
- {
- int num{ 33 };
- int* ptrInt{ nullptr };
- bool* ptrBool{ nullptr };
- float* ptrFloat{ nullptr };
- char* ptrChar{ nullptr };
- ptrInt = new int{ 33 };
- ptrBool = new bool[3]{ true,false,true };
- ptrFloat = new float{ 42.1 };
- ptrChar = new char[10]{ 'H','e','l','l','o','!' };
- //arr[i] <=> *(arr+i)
- ptrBool[1] = true;
- *(ptrBool + 1) = true;
- *ptrInt = 44;
- ptrInt[0] = 44;
- delete ptrInt;
- delete[] ptrBool;
- delete ptrFloat;
- delete[] ptrChar;
- ptrInt = #
- //delete ptrInt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement