相关疑难解决方法(0)

为什么"使用命名空间std"被认为是不好的做法?

我已经告诉别人,编写using namespace std;代码是错误的,我应该用std::coutstd::cin直接代替.

为什么被using namespace std;认为是不好的做法?是低效还是冒着声明模糊变量(与名称std空间中的函数具有相同名称的变量)的风险?它会影响性能吗?

c++ namespaces using-directives std c++-faq

2486
推荐指数
36
解决办法
78万
查看次数

C++模块 - 为什么它们从C++ 0x中删除?他们以后会回来吗?

我刚刚发现关于C++ 0x中模块的旧C++ 0x草案.

我们的想法是通过只编写.cpp文件退出当前的.h/.cpp系统,然后在编译过程中生成模块文件,然后由其他.cpp文件使用.

这看起来非常棒.

但我的问题是:为什么他们从C++ 0x删除它?是因为太多的技术难题?时间不够?你是否认为他们会考虑使用它来获得一个不可思议的C++版本?

c++ standards module language-extension c++11

110
推荐指数
3
解决办法
3万
查看次数

#include <bits/stdc ++.h>如何在C++中工作?

我从读codeforces博客,如果我们#include <bits/stdc++.h>在一个C++程序那么就没有必要包括任何其他的头文件.如何#include <bits/stdc++.h>工作,是否可以使用它而不是包括单独的头文件?

c++ gcc g++ c++11

108
推荐指数
4
解决办法
13万
查看次数

为什么使用预编译头(C/C++)?

快速提问 - 为什么要使用预编译标题?

编辑:阅读回复,我怀疑我一直在做的事情有点愚蠢:

#pragma once

// Defines used for production versions

#ifndef PRODUCTION
#define eMsg(x) (x) // Show error messages
#define eAsciiMsg(x) (x)
#else
#define eMsg(x) (L"") // Don't show error messages
#define eAsciiMsg(x) ("")
#endif // PRODUCTION

#include "targetver.h"
#include "version.h"

// Enable "unsafe", but much faster string functions
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS

// Standard includes
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <direct.h>
#include <cstring>
#ifdef _DEBUG
#include <cstdlib>
#endif

// Standard Template Library
#include <bitset>
#include …
Run Code Online (Sandbox Code Playgroud)

c++ precompiled-headers

42
推荐指数
5
解决办法
3万
查看次数

我应该包括每个标题吗?

我是否应该包括每个标题,即使之前包括它?或者我可以尽可能地避免它?例如.如果我使用std::stringstd::vector在某些文件中.如果<string>包含<vector>我应该只包括<string><string><vector>

c++ c++11

17
推荐指数
2
解决办法
1629
查看次数