[ create a new paste ] login | about

Link: http://codepad.org/0fSl8FKX    [ raw code | output | fork ]

C++, pasted on Jun 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdlib.h>
#include <stdio.h>
int getLength(double c[]);

template<typename T, int size>
int length(T(&)[size])
{
   return size;
}

int main()
{
    double c[] = {1.0, 2.0, 3.0, 4.0};
    printf("%d\n", length(c));

return 0;
}


Output:
1
4


Create a new paste based on this one


Comments: