是否可以在不重写派生类中记录虚拟成员?

Can I document a virtual member in a derived class without overriding it?

本文关键字:记录 虚拟成员 派生 重写 是否      更新时间:2023-10-16

假设我有一些外部库,其中包含一个未记录的基类:

class Base {
public:
virtual void func() { /* something */ }
}

在我的库中,我想从这个类派生,并记录所有成员:

class Derived : public Base {
/*!
@brief do a thing
*/
void other_func();
/*!
@brief do the base thing and another thing
*/
void func(int arg);
/*!
@brief do the baseclass thing
Also, guarantee some extra invariants XYZ that the baseclass
does, but does not require subclassers to do.
*/
using Base::func;
// virtual void func() override;
// don't want to declare a new implementation of func() here
// so how can I attach a docstring to func() such that doxygen picks up on it?
}

如何在Derived.h中记录继承的Base::func

使用 @fn 标签。您可以使用该标签并指定函数签名,然后该块的其余部分将分配给该函数。

对不起,我会举一个例子,但在电话里。

我会链接到官方文档,但令人沮丧,有点讽刺的是,doxygen的参考网站在移动设备上不起作用。所以只是谷歌它。