#include <stdio.h> int main(int argc, char *argv[]) { int x = 2; int y = x; int* p1 = &x; int* p2 = p1; printf("只拷贝值,不拷贝地址 "); printf("深拷贝:x = %p,value = %d ",&x,x); printf("深拷贝:y = %p,value = %d ",&y,y); printf("只拷贝地址,不拷贝值 "); printf("浅拷贝:p1 = %p,value = %d ",p1,*p1); printf("浅拷贝:p2 = %p,value = %d ",p2,*p2); return 0; } /* ---------- 运行c ---------- 只拷贝值,不拷贝地址 深拷贝:x = 0060FEF4,value = 2 深拷贝:y = 0060FEF0,value = 2 只拷贝地址,不拷贝值 浅拷贝:p1 = 0060FEF4,value = 2 浅拷贝:p2 = 0060FEF4,value = 2 输出完成 (耗时 0 秒) - 正常终止 */