1. for中定义变量作用域不同

for (int i=0; i<100; i++){}
for (int i=100; i<200; i++){}

以上代码在VS2008中可编译通过;在VC6.0下会提示" 'i' : redefinition "的编译错误。

2. static const变量能否在头文件中初始化

class A
{
public:
	static const int m_MAXNUM = 10;
};

以上代码在VS2008中可编译通过;在VC6.0下会提示出两个令人费解的编译错误。

error C2258: illegal pure syntax, must be '= 0'

error C2252: 'm_MAXNUM' : pure specifier can only be specified for functions

将代码修改为以下即可通过编译

//a.h
class A
{
public:
	static const int m_MAXNUM;
};
// a.cpp
const int A::m_MAXNUM = 10;

 

这些差异是我们需要在移植代码时考虑的,紧记!

相关文章:

  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-01-21
  • 2021-12-27
  • 2021-12-12
猜你喜欢
  • 2022-02-04
  • 2021-05-16
  • 2021-12-07
  • 2022-01-13
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
相关资源
相似解决方案