考虑到:
char* ptr; // 1) a non-constant pointer to a non-constant char
const char* ptr; // 2) a non-constant pointer to a constant char
char* const ptr; // 3) a constant pointer to a non-constant char
const char* const ptr; // 4) a constant pointer to a constant char
当我写:
#include <iostream>
template <class T>
void f(const T ptr)
{;}
int main(int argc, char* argv[])
{
char a = 'a';
f(&a);
return 0;
}
2) 或 3)的类型是什么ptr
?