1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include<iostream> #include <stdint.h> using namespace std; int fun1(int a) { return a*a; } void man(int &a) { a=a*a; } void cubeByReference(int *a) { *a=*a * *a; }
void fun2(uint8_t* *buffer) { uint8_t buf[10]={0,1,2,3,4,5,6,7,8,9}; *buffer = buf; } int main() { int a=5,b=5,number=5; cout<<fun1(a)<<endl; man(b); cout<<b<<endl; cubeByReference(&number); cout<<number<<endl;
uint8_t *buf; fun2(&buf); printf("%d\n", buf[0]); return 0; }
|