gpt4 book ai didi

c++ - C++运算符重载时的垃圾值

转载 作者:太空宇宙 更新时间:2023-11-04 15:54:42 26 4
gpt4 key购买 nike

我只是得到垃圾值。调试器显示正确的值很奇怪。但是它打印了一些奇怪的东西...

这第一部分很好。本质上,它只是带我解决我的问题。我有我需要在 h.hashtable[hashIndex] 数组中打印的内容。

ostream& operator<<(ostream& out, const hashmap& h)
{
const char *getSymbol = NULL;
for ( int hashIndex = 0; hashIndex < maxSize; hashIndex++ )
{
getSymbol = h.hashTable[hashIndex].getSymbol();
if ( getSymbol ) // Find the one I added.
{
h.hashTable->display(out);
return out << h.hashTable[hashIndex];
}
}
return out;
}

最佳答案

确保流设置为以十进制打印

out << dec << s.m_sharePrice;

(m_sharePrice 是非指针类型,对吧?)

关于c++ - C++运算符重载时的垃圾值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1528981/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com