예를 들어,네임 스페이스 식별자가 모든 매개 변수 앞에 있어야합니까?
Matrix.h는
namespace Matrix
{
class mat
{
public:
mat(int row, int col);
const mat &operator=(const mat &rhs);
}
}
Matrix.cpp
Matrix::mat::mat(int row, int col)
{ // implementation here }
const Matrix::mat &Matrix::mat::operator=(const mat &rhs)
{ // implementation here }
위 코드는 문제없이 컴파일됩니다. 문제는 앞에서 const mat operator=(const Matrix::mat &rhs);
과
const Matrix::mat Matrix::mat::operator=(const Matrix::mat &rhs)
과 같은 네임 스페이스 식별자를 앞에 붙여야합니까? 왜 그렇게하는 컨벤션 방법이며 식별자를 추가하지 않고 컴파일하는 이유는 무엇입니까?
이러한 방법으로 "namespace Matrix {...}"를 사용하거나 그렇게 할 수 있습니다. 나는 후자를 선호한다. – memo1288