프로그래밍/C++34 디폴트 매개변수 이것도 뭐 특별한거 없다. 말 그대로 인자값을 넣어주지 않아도 자동으로 변수의 값을 잡아 주는 것인데, 간단한 주의점과 사용법은 예제를 참고하자. 함수 오버로딩시에 주의점. #include void temp(int a=10);// 문제 없다. void temp(int a, int b = 10 );// 함수 오버로딩 같지만 // 왠지 문제 있어 보이지 않는가? void main() { temp(10);// 난 누구한테 가야 하나요? } 이번엔 또다른 주의점 #include void temp(int a=10, char b='c');// 문제 없다. void temp(int a=10, int b );// 얼핏 보면 문제 없어 보일지도 모르나 void main() { temp(10);// 10이라는 숫자는 a도.. 2010. 3. 15. 함수 오버로딩 (overloading) #include void temp(); void temp(int a); void temp(int a, int b); void temp(char a); void main() { temp(); temp(1); temp(1,1); temp('c'); } void temp() { std::cout 2010. 3. 15. putback(), peek() puback(char type) char타입을 꺼낸다고 보면 된다. 예제로 이해 하는것이 빠를듯, #include void main() { char c[10], c2, c3; // 입력 값으로 "qw"를 입력하면, c2 = std::cin.get( );// c2에 'q' c3 = std::cin.get( );// c3에 'w'가 들어 가게 된다. std::cin.putback( c2 );// putback을 사용해서 'q'를 꺼내고 std::cin.getline( &c[0], 10 );// c에 'q'만을 삽입하게 된다. std::cout 2010. 3. 15. cout, cin, endl 특별한 건 없고, c언어의 printf와 scanf, "\n"(개행)에 대한 변경 되었다고 보면 될듯 하다. #include void main() { int n1; std::cin >> n1; std::cout 2010. 3. 15. 이전 1 ··· 3 4 5 6 다음