笔记

int*型

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int val = 5;
    int *ptr = &val;
    int * &ptr2 = ptr;    //ptr2是int* 型,是对str的引用;
    *ptr = 6;
    cout << val << " " << *ptr <<" "<< *ptr2 << endl;
    *ptr2 = 7;
    cout << val << " " << *ptr << " " << *ptr2 << endl;
    cout << &val << " " << ptr << " " << ptr2 << endl;
    delete ptr;
    delete ptr2;
}
/*
6 6 6
7 7 7
0x61fe3c 0x61fe3c 0x61fe3c
*/
上一篇:C语言中ctime()和loacaltime()使用中遇到的问题


下一篇:2021-06-18