1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include <iostream>
- int* func()
- {
-
-
- int * p = new int(10);
- return p;
- }
- void test01()
- {
- int* p = func();
- std::cout << *p << std::endl;
- std::cout << *p << std::endl;
- std::cout << *p << std::endl;
-
-
- delete p;
-
- }
- void test02()
- {
-
- int* arr = new int[10];
- for (int i = 0; i < 10; i++)
- {
-
- arr[i] = i + 100;
- }
- for (int i = 0; i < 10; i++)
- {
- std::cout << arr[i] << std::endl;
- }
-
-
- delete[] arr;
- }
- int main()
- {
- test01();
- test02();
- system("pause");
- return 0;
- }
|