Array parsing in C++ is always done by reference, and in std there's no concept of parsing by value. From a stakoverflow question I summarize this below. The array size information is lost here. void by_pointer(int *p, int size); void by_pointer(int p[], int size); void by_pointer(int p[7], int size); // the 7 is ignored in this context! void by_reference(int (&a)[7]); // only arrays of size 7 can be passed here! template void by_reference(int (&a)[size]); void TestMethod(char cArray[], int size) { const char* pTest = "test"; strncpy(cArray, pTest, size); cArray[ size-1] = '\0'; } Usage: char cMyArray[7] = {a}; TestMethod(cMyAray, 7} However this can be quite tricky to understand. Take the problem of dynamic resizing of an array. unsigned int iArrSize = 10; int *iArr = new int[iArrSize]; for (int i = 0; i < 100; i++) { ...
Programming, Machine Learning and Capital Markets