搜尋此網誌

[C/C++][別名]

/*
* File Name: AliasUsingDereference.c
* Author: MH
* Since 2013/04/01
* Toolkit: Dev C++ 4.9.9.9
*/

#include <stdio.h>

int main(){

    int x = 5;
    int *p;

    p = &x;
    printf("*p = %d\n", *p);

    *p = 6;
    printf("x = %d", x);

    return 0;
}

/*
* File Name: AliasUsingReference.c
* Author: MH
* Since 2013/04/01
* Toolkit: Dev C++ 4.9.9.9
*/

#include <stdio.h>

int main(){

    int a = 5;
    int &b = a;

    printf("b = %d\n", b);

    b = 6;
    printf("a = %d", a);

    return 0;
}

沒有留言:

張貼留言