c++ overload 에러...

i_wish_awk_sed_perl의 이미지

c++ 초보입니다. c를 공부하다가 이번에 c++도 공부할 생각으로 책을 보며 공부하고 있는데...잘 안되네요. 책에 있는 예제입니다만...컴파일 할때 에러가 납니다.

#include <iostream>

using namespace std;

template <typename any>
void swap(any &a, any &b);

template <typename any>
void swap(any *a, any *b, int n); 

void show(int a[]);

const int limit = 8;

int main(void)
{
    int i = 10; 
    int j = 20; 

    int arrayOne[limit] = {0, 7, 0, 4, 1, 7, 7, 6};
    int arrayTwo[limit] = {0, 6, 2, 0, 1, 9, 6, 9};

    cout << i << " " << j << endl;

    swap(i, j);

    cout << i << " " << j << endl;

    show(arrayOne);
    show(arrayTwo);

    swap(arrayOne, arrayTwo, limit); 

    show(arrayOne);
    show(arrayTwo);

    return(0);
}

template <typename any>
void swap(any &a, any &b) 
{
    any tmp;
    tmp = a;
    a = b;  
    b = tmp;
}

template <typename any>
void swap(any *a, any *b, int n)
{
    any tmp;

    int i;  

    for(i = 0; i < n; i++) 
    {
        tmp = *(a + i);
        *(a + i) = *(b + i);
        *(b + i) = tmp;
    }
}

...
...

에러는...

Quote:

ftemplate2.cpp: In function `int main()':
ftemplate2.cpp:27: error: call of overloaded `swap(int&, int&)' is ambiguous
ftemplate2.cpp:8: error: candidates are: void swap(any&, any&) [with any = int]
/usr/include/c++/3.3/bits/stl_algobase.h:121: error: void
std::swap(_Tp&, _Tp&) [with _Tp = int]

입니다. 으흠...왜 이런지?

i_wish_awk_sed_perl의 이미지

아...이런... swap 이라는 함수가 이미 존재하는군요. 음...근데 man swap 해도 맨페이지에는 나오지 않네요. 혹시 데비안에서 c++ 용 함수 맨페이지는 어떤 패키지에 들어 있는지요?

제가 설치한 페키지는

Quote:

ii manpages 1.67-2 Manual pages about using a GNU/Linux system
ii manpages-dev 1.67-2 Manual pages about using GNU/Linux for devel
ii manpages-ko 20010901-0.1 Korean version of the manual pages
ii manpages-posix 1.67-3 Manual pages about using POSIX system
ii manpages-posix 1.67-3 Manual pages about using a POSIX system for

입니다.

언제쯤 정규표현식을 정복할 수 있을까? ㅡㅡ;