c++11 부터는 디폴트 매개변수로 구조체를 넣을 수 있던데 배열이나 포인터 같은것도 가능하나요?
int arr[] = {1,2,3}; void f(int array[] = arr, int *ptr = new int, std::vector<int> vec={1,2,3}) {}
찾아보니 다양한 예제가 있네요.
void myFunction(int myArray[] = array) { std::cout << "First value of array is: " << myArray[0] << std::endl; // Note that you cannot determine the length of myArray! }
nullprt로 설정하는 방법도 있습니다.
void myFunction(int myArray[] = nullptr ) { // ^^^^^^^ }
개인 블로그https://codingcoding.tistory.com
int arr[] = {1,2,3};
이런 방법들이 있습니다.
c++ 11 default parameter + array, pointer
찾아보니 다양한 예제가 있네요.
void myFunction(int myArray[] = array) { std::cout << "First value of array is: " << myArray[0] << std::endl; // Note that you cannot determine the length of myArray! }nullprt로 설정하는 방법도 있습니다.
void myFunction(int myArray[] = nullptr ) { // ^^^^^^^ }개인 블로그
https://codingcoding.tistory.com