c++11 - 我在链接中的整数插入程序从 16 开始转换整数:(2,4,6,8,10,12,14,875311656,942421548,741355820)
问题描述
这是我实现的链接类的插入方法,数据类型是整数(typedef int TELEM)。通过显示存储的数字,从16开始显示其他值太大
包括
typedef int TELEM;
// liste d'éléments de type TELEM
class liste {
public:
liste::liste() : m_nb(0) ,m_tetefile(0)
{
m_tetefile = new TELEM[m_nb+1] ;
}
liste::~liste()
{
m_nb = 0;
delete m_tetefile;
}
bool liste::est_vide() const
{
return m_nb == 0;
}
int liste::taille() const
{
return m_nb;
}
const TELEM& liste::operator[](int i) const
{
assert((i>=1) && (i<=m_nb));
return (m_tetefile[i]);
}
void liste::inserer(const TELEM& e, int i)
{
assert((i>=1) && (i<=m_nb+1));
for (int k = m_nb ; k >= i ; --k)
m_tetefile[k+1] = m_tetefile[k];
m_tetefile[i] = e;
std::cout << e <<std::endl;
std::cout << m_tetefile[i] <<std::endl;
m_nb++;
}
private:
TELEM m_nb ;
TELEM *m_tetefile;
};
std::ostream& operator<<(std::ostream& os, const liste& l)
{
os << '(';
if (!l.est_vide())
os << l[1];
for (int i=2; i<=l.taille(); ++i)
os << ',' << l[i];
os << ')';
return os;
}
从 16 ca 给我这个 (2,4,6,8,10,12,14,875311656,942421548,741355820) 而不是 (2,4,6,8,10,12,14,16,18,20)
解决方案
推荐阅读
- django - 向查询集序列化程序添加额外字段
- php - 使用 API JSON 根据第一个下拉列表填充第二个下拉列表
- flutter - 如何将视频放入 listview builder 中?
- spring-boot - java.lang.NoSuchMethodError: org.mockito.MockingDetails.getMockCreationSettings() - Gradle links same class twice for Mockito jar
- javascript - 突出列差异
- r - Set date value in time series based on value in previous row
- firebase - 您试图通过调用 firebase.app() 来使用未安装在您的 Android 项目上的 firebase 模块
- android - Flutter Blue 未检测到蓝牙打印机 (Zebra ez320)
- triggers - 如何在zabbix中创建用于检查应用服务状态的触发器
- flutter - How to make custom Bottom Navigation Bar in Flutter