关于stl的一个现象,大家讨论一下
代码如下:
#include "stdafx.h"
#include <string>
#include <vector>
#include <map>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> v;
int debug;
if(0 > (v.size()-100))
{
debug = 1;
}
else
{
debug = 2;
}
return 0;
}
其结果为debug = 2,为什么?
在vs2005和vc6.0下是这种结果,其他版本没有试验过,其中vs2005是安装了sp1补丁的
将代码改成如下这样
#include "stdafx.h"
#include <string>
#include <vector>
#include <map>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> v;
int debug;
int c = (v.size()-100);
if(0 > c)
{
debug = 1;
}
else
{
debug = 2;
}
return 0;
}
其结果为debug = 1
#include "stdafx.h"
#include <string>
#include <vector>
#include <map>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> v;
int debug;
if(0 > (v.size()-100))
{
debug = 1;
}
else
{
debug = 2;
}
return 0;
}
其结果为debug = 2,为什么?
在vs2005和vc6.0下是这种结果,其他版本没有试验过,其中vs2005是安装了sp1补丁的
将代码改成如下这样
#include "stdafx.h"
#include <string>
#include <vector>
#include <map>
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> v;
int debug;
int c = (v.size()-100);
if(0 > c)
{
debug = 1;
}
else
{
debug = 2;
}
return 0;
}
其结果为debug = 1
...全文
相关推荐
手工制作一个STL文件
在“手工制作一个STL文件”的过程中,我们需要深入了解STL文件的基本结构和三角形面片的数据表示。STL文件格式的基础是通过一系列相互连接的三角形面片来构建3D模型。
C++ STL find_if使用的一个完整例子
`find_if`是STL中的一个算法,它用于在一个范围内的元素序列中查找第一个满足特定条件的元素。在这个例子中,我们将详细探讨`find_if`的使用以及如何在实际代码中应用它。
stlshow_stl分层_STL分层_stlmatlab_STL切片_stl分层
`stlread.m`可能是一个读取STL文件的MATLAB函数,而`ui.m`可能包含用户界面元素,用于交互式设定分层参数。在MATLAB中,STL文件的读取通常涉及以下步骤:1.
stl 电子书两本(C++ STL使用教程,STL编程)
这两本电子书《C++ STL使用教程》和《STL编程》无疑会深入探讨STL的核心概念和实践应用。STL的主要组成部分包括:1. 容器:这是STL的基础,提供了一种组织和存储数据的方式。
stl文件在matlab中的读取.zip_matlab 点云stl_matlab与STL文件_matlab读取stl_stl点云
### STL文件格式简介STL文件格式由3D打印和快速原型制造领域发展而来,它以三角面片的形式描述物体表面。每个三角形由三个顶点坐标和一个法向量组成,法向量定义了三角面片的朝向。


