为头创建的源文件文件
我有一个文件GetL.hxx为头创建的源文件文件
#ifndef GetL_included
#define GetL_included
#include <iostream>
using namespace std;
class GetL
{
public:
virtual int getWidth();
};
#endif //GetL_include
这里的类GetL只包含一个虚函数。我应该把在源文件即GetL.cxx
#include "GetL.hxx"
int GetL::getWidth() {
// your code goes here
}
顺便说一句,在头文件is not a good practice有using namespace std;
。
我怎么可以'#include
我想创建一个虚拟方法,以便可以继承GetL类并覆盖getWidth方法。如果我给出这样的实现,它会击败我创建它的原因。 – 2012-02-22 09:26:54
如果#include
你应该在末尾有'#endif //!GetL_included'。 – 2012-02-22 09:27:05
@AdeYU你能解释一下这个区别吗 – 2012-02-22 09:32:39
可能是[用C++创建hxx文件的cxx文件]的副本(http://stackoverflow.com/questions/9390953/create-cxx-file-for-hxx-file-in- c) – 2012-02-22 09:49:23