为头文件创建源文件

Create Source file for Header file

本文关键字:源文件 文件创建      更新时间:2023-10-16

我有一个文件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
}

顺便说一句,在头文件中包含using namespace std;不是一个好的做法。