//测试环境 visual studio 2012 变量 a
//a) 一个整型数(An integer)
//b) 一个指向整型数的指针(A pointer to an integer)
//c) 一个指向指针的的指针,它指向的指针是指向一个整型数(A pointer to a pointer to an integer)
//d) 一个有10个整型数的数组(An array of 10 integers)
//e) 一个有10个指针的数组,该指针是指向一个整型数的(An array of 10 pointers to integers)
//f) 一个指向有10个整型数数组的指针(A pointer to an array of 10 integers)
//g) 一个指向函数的指针,该函数有一个整型参数并返回一个整型数(A pointer to a function that takes an integer as an argument and returns an integer)
//h) 一个有10个指针的数组,该指针指向一个函数,该函数有一个整型参数并返回一个整型数( An array of ten pointers to functions that take an integer argument and return an integer )
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
int a = 1;
int *b = NULL;
int **c = NULL;
int d[10] = {1,1,1,1,1,1,1,1,1,1};
int *e[10];
int (*f)[3];
int ff[3][3] = {1,2,3,4,5,6,7,8,9};
int (*g)(int);
int (*h[3])(int);
int test1(int x)
{
std::cout << " x = " << x << std::endl;
return x;
}
int test2(int x)
{
std::cout << " x = " << x << std::endl;
return x;
}
int test3(int x)
{
std::cout << " x = " << x << std::endl;
return x;
}
int print(int x)
{
std::cout << " x = " << x << std::endl;
return x;
}
int main()
{
std::cout << "------------------------" << std::endl;
int test = 5;
b = &test;
std::cout << "*b= " << *b << " b = " << b << std::endl;
c = &b;
std::cout << "**c= " << **c << " *c= " << *c << " c = " << c << std::endl;
std::cout << "------------------------" << std::endl;
e[0] = b;
e[1] = *c;
std::cout << "e[0] = " << e[0] << " e[1] = " << e[1] << std::endl;
f = ff;
std::cout << "f= " << f << " f1= " << *f[0] << " f2= " << *f[1] << " f3= " << *f[2] << std::endl;
std::cout << "------------------------" << std::endl;
print(6);
g = print;
g(7);
std::cout << "g= " << g << std::endl;
test1(1);
test2(2);
test3(3);
h[0] = test1;
h[1] = test2;
h[2] = test3;
h[0](4);
h[0](5);
h[0](6);
std::cout << "------------------------" << std::endl;
while(1);
return 0;
}