在C++定义文件(的.cpp),有时我可以定义小的功能将被调用,例如:在C++定义文件中的功能扩展(CPP)
// Class declaration
// Myclass.h
Class Myclass
{
...
void Classfunction();
...
}
// Class defination
// Myclass.cpp
#include "Myclass.h"
...
void helper_fun()
{
...
}
...
void Myclass::Classfunction()
{
...
helper_fun();
...
}
在上述例子中,我们可以看到void helper_fun()是在.cpp文件中声明和定义的。这个函数的目的是由类中定义的函数调用。当然,helper_fun可以在头文件中声明,然后在实现文件中定义。我的问题是,这是否是C++代码编写的好习惯。而且,这种做法是否有一些不好的影响?谢谢!
+1为匿名命名空间提示 – 2012-07-31 11:19:41