标签:
// AllPointFunc1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; //指针函数 int *func1(int i) { return &i; } //和func1相同 int* func2(int i) { return &i; } //指针函数 int *func3(int *i) { return i; } //普通函数 int func4(int i) { return ++i; } int main() { int k = 3; cout << "\n=====\tfunc1\t=====" << endl; cout << "func1(k) : " << func1(k)<< "\n*func1(k) : " << *func1(k) << endl; cout << "\n=====\tfunc2\t=====" << endl; cout << "func2(k) : " << func2(k) << "\n*func2(k) : " << *func2(k) << endl; cout << "\n=====\tfunc3\t=====" << endl; cout << "func3(k) : " << func3(&k) << "\n*func(3) : " << *func3(&k) << endl; cout << "\n=====\tfunc4\t=====" << endl; cout << "(*func4)(k) : " << (*func4)(k) <<"\nfunc4(k) : " << func4(k) << endl; //函数指针 int(*Pfunc4)(int); Pfunc4 = &func4; cout << "\n=====\tPfunc\t=====" << endl; cout << "(*Pfunc4)(k) : " << (*Pfunc4)(k) << "\nPfunc4(k) : " << Pfunc4(k) << endl; return 0; }
标签:
原文地址:http://www.cnblogs.com/qiangwushuang/p/4941927.html