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
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
int arr[] = {1,2,3};
이런 방법들이 있습니다.
c++ 11 default parameter + array, pointer
찾아보니 다양한 예제가 있네요.
nullprt로 설정하는 방법도 있습니다.
개인 블로그
https://codingcoding.tistory.com
댓글 달기