我已经告诉别人,编写using namespace std;代码是错误的,我应该用std::cout和std::cin直接代替.
为什么被using namespace std;认为是不好的做法?是低效还是冒着声明模糊变量(与名称std空间中的函数具有相同名称的变量)的风险?它会影响性能吗?
我们的想法是通过只编写.cpp文件退出当前的.h/.cpp系统,然后在编译过程中生成模块文件,然后由其他.cpp文件使用.
这看起来非常棒.
但我的问题是:为什么他们从C++ 0x删除它?是因为太多的技术难题?时间不够?你是否认为他们会考虑使用它来获得一个不可思议的C++版本?
我从读codeforces博客,如果我们#include <bits/stdc++.h>在一个C++程序那么就没有必要包括任何其他的头文件.如何#include <bits/stdc++.h>工作,是否可以使用它而不是包括单独的头文件?
快速提问 - 为什么要使用预编译标题?
编辑:阅读回复,我怀疑我一直在做的事情有点愚蠢:
#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) 我是否应该包括每个标题,即使之前包括它?或者我可以尽可能地避免它?例如.如果我使用std::string和std::vector在某些文件中.如果<string>包含<vector>我应该只包括<string>或<string>和<vector>?