如何从 Visual Studio IntelliSence 提示中隐藏私有重载函数?

Ros*_*ets 2 c++ intellisense

我有这门课:

class BST
{
public:
   void insert(int val) { insert(node, val); }
private:
   void insert(std::shared_ptr<Node> node, int i);
   std::shared_ptr<Node> node = nullptr;
};
Run Code Online (Sandbox Code Playgroud)

这里我为类用户插入了公共函数。以及 if 的私有重载版本。当我想从驱动程序代码调用此函数时,在 IntelliSence 提示中我有此函数的两个重载。 在此输入图像描述

那么是否有办法对用户隐藏私有功能呢?

S.M*_*.M. 5

您可以使用宏__INTELLISENSE__从 IntelliSense 建议中隐藏类成员。

class BST {
 public:
  void insert(int val) { insert(node, val); }

 private:
#ifndef __INTELLISENSE__ 
  void insert(std::shared_ptr<Node> node, int i);
#endif

  std::shared_ptr<Node> node = nullptr;
};
Run Code Online (Sandbox Code Playgroud)

这里给出的提示是:IntelliSense 缓慢的故障排除提示

不幸的是,这不是一个足够好的解决方案。即使在正确的访问范围内,它也会在自己的类方法中隐藏建议。