[질문]볼렌드c++에서 template을 사용하는데 에러가 ㅡㅜ
글쓴이: hshthsh / 작성시간: 금, 2004/08/13 - 4:01오후
안녕하세요.
볼렌드 c++5.5를 이용해 template함수를 정의했는데 에러가 나는데 도통 이유를 모르겠습니다. 아래와 같이 정의했더니...
template <> double _max<box>(const box & b1,const box & b2)
{
return (b1.volume > b2.volume)?b1.volume:b2.volume;
}
이런 에러가 나와서..
^Type mismatch in redeclaration of '_max<box>(const box &,const box &)'
^Earlier declaration of '_max<box>(const box &,const box &)'
전달인자에const만 빼고 다시 이렇게 바꿔보니..
template <> double _max<box>(box & b1,box & b2)
{
return (b1.volume > b2.volume)?b1.volume:b2.volume;
}
이제는 이런에러가 나더니..
^Explicit specialization or instantiation of non-existing template '_max'
마지막으로 이렇게 바꾸니 에러가 나지 않던데 혹시 이유를 하시는분 ㅡㅜ
double _max<box>(box & b1,box & b2)
{
return (b1.volume > b2.volume)?b1.volume:b2.volume;
}
Forums:
[code:1]template <> double _max&
템플릿에서 위와 같은 코드가 원래 컴파일 되는건가요?
저라면
이렇게 코딩했을 것 같은데..
서로 기능이 다른가요?
템플릿 특수화를 하려고 하셨던 겁니까? 그렇다면 다음과 같이 일반적인 것
템플릿 특수화를 하려고 하셨던 겁니까? 그렇다면 다음과 같이 일반적인 것을 먼저 정의해야죠.
댓글 달기