📜  c++ 数组中的元素数 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:37.331000             🧑  作者: Mango

代码示例1
#include 
using std::cout;

int a[] = { 1, 2, 3, 4, 5 };
int counta()
  {
  return sizeof( a ) / sizeof( a[ 0 ] );  // works, since a[] is an array
  }

int countb( int b[] )
  {
  return sizeof( b ) / sizeof( b[ 0 ] );  // fails, since b[] is a pointer
  }