本地#includes [英] local #includes

查看:98
本文介绍了本地#includes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有某种方法可以局部(而不是全局)#include标准内容(一次针对一个函数,一个类等).以一个非常简单的示例为例,可能要使用std :: string,但仅在一个类中需要它,并且您不希望它的开销到处都是.

Is there some way to #include standard things locally (for one function, one class, etc... at a time) instead of globally. Taking a very simple example one might want to use std::string but it is only needed in one class and you don't want the overhead of it existing everywhere.

推荐答案

您可能应该将需要它的类移到单独的文件中,而不是将#include设置为本地.

Instead of making #include local, you should probably just move the class that requires it into a separate file.

这篇关于本地#includes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆