这是我的示例代码:
#include <iostream>
#include <cstring>
#include <vector>
#include <iterator>
#include "MQmessage.h"
using namespace std;
int main()
{
// declaring an array to store name/value pair
struct Property user_property[15];
const char* const list[] = {"stateCode","errorCode"};
const size_t len = sizeof(list) / sizeof(list[0]);
for (size_t i = 0; i < len; ++i) {
strcpy(user_property[0].name,list[i]);
}
for (size_t i = 0; i < len; ++i) {
std::cout<<user_property[i]<<endl;
}
return 0;
}
我在代码中遇到以下错误:
no match for 'operator<<' in std::cout
谁能告诉我我做错了什么?
最佳答案
我猜你想要 std::cout<<user_property[i].name<<endl
,否则你将不得不重载 <<
Property
的运营商.
关于c++ - 编译时字符串数组错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12794498/