You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

尝试将类和对象放入头文件时遇C++下标错误求助

头文件中类与对象定义引发的数组下标错误排查

我最近试着把类和对象放到头文件里,结果一直卡着一个错误提示:subscript requires array or pointer type,实在摸不准是头文件引用得不对,还是代码本身写岔了。这个错误出现在第28行的iItemPrice[iCount]位置,相关的代码片段我贴在下面:

#include "stdafx.h"
#include <string>
#include <conio.h>
#include <array>
#include <vector>
#include "ItemsClass.h"
#include "A2main.cpp"
#include <iostream>
using namespace std;

ItemsClass::ItemsClass() { }

void ItemsClass::enter_items() { 
    string ...
}

内容的提问来源于stack exchange,提问作者limpz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 02:23:43