class MDeviceInfo { public: MDeviceInfo(MChannelInfo* info) : channelInfo(info) , deviceParInfo() , dataInfo() { ; } MDeviceInfo() {}; ~MDeviceInfo(); QString name; QString describe; QStringList info; QStringList deviceParInfo; QStringList dataInfo[5]; MChannelInfo* channelInfo;}这个类实例化对象后static MDeviceInfo cpDeviceInfo; 关闭程序时报错inline int size() const noexcept { return int(d->end - d->begin); }引发了未经处理的异常:读取访问权限冲突。 this 是 0x1C。 问题原因如何改装
时间: 2024-01-09 10:04:13 浏览: 34
这个错误的原因可能是因为在程序退出时,`cpDeviceInfo` 对象被销毁,但是其成员 `channelInfo` 指针指向的对象可能在此之前已经被销毁了。当程序试图访问已经销毁的对象时,就会发生访问权限冲突的错误。
解决这个问题的方法是在 `MDeviceInfo` 的析构函数中,释放 `channelInfo` 指针指向的对象,以确保其在对象销毁时也被正确释放。例如:
```cpp
MDeviceInfo::~MDeviceInfo()
{
delete channelInfo;
}
```
另外,你在代码中出现了 `dataInfo[5]`,这似乎是一个数组,但是你在初始化列表中将其当做字符串列表来处理。如果你想要一个数组,可以这样定义:
```cpp
QStringList dataInfo[5];
```
但是需要注意的是,这样定义的数组大小是固定不变的,如果你需要动态改变数组大小,可以使用 `std::vector` 等容器代替数组。
相关问题
String requestData = AESUtils.decrypt(aesKey,aesIv,jsonObject.getString("requestData")); JSONObject requestDataObject = JSONObject.parseObject(requestData); String mobile = requestDataObject.getString("mobile"); String channelId =jsonObject.getString("channelId"); if (!MobileUtils.isNumLegal(mobile)){ map.put("code","400"); map.put("message","手机号格式异常"); return map; } //加密参数 ChannelInfo channelInfo = new ChannelInfo(); channelInfo.setChannelCode(channelId); List<ChannelInfo> channelInfos = channelInfoMapper.selectChannelInfoList(channelInfo); if (channelInfos.isEmpty()){ map.put("message","渠道参数异常"); map.put("code","400"); return map; }这段代码是什么意思
这段代码是一个Java代码段,主要实现了通过AES解密请求数据、获取其中的手机号和渠道ID等信息,并进行一些判断和处理。具体来说:
- 第一行代码使用AESUtils工具类对请求数据进行解密,其中aesKey和aesIv是解密用的密钥和向量,jsonObject是一个JSON对象,其中包含了加密后的请求数据。
- 第二行代码将解密后的请求数据转换为JSON对象,然后获取其中的手机号。
- 第三行代码获取JSON对象中的渠道ID。
- 第四行代码使用MobileUtils工具类判断手机号是否合法,如果不合法则返回错误信息。
- 第六行代码创建一个ChannelInfo对象,并设置其渠道编码为获取到的渠道ID。
- 第七行代码调用channelInfoMapper的selectChannelInfoList方法查询符合条件的渠道信息,将结果保存在channelInfos列表中。
- 第八行代码判断channelInfos列表是否为空,如果为空则说明渠道参数异常,返回错误信息。
springboot调用别人传过来的渠道与机构计算机构分摊费用
可以考虑使用SpringBoot的RESTful API实现该功能。具体实现步骤如下:
1. 定义一个Controller,用于接收外部传递的渠道和机构信息,并返回分摊费用的计算结果。
2. 在Controller中,使用@RequestParam注解获取外部传递的渠道和机构信息。
3. 根据传递的渠道和机构信息,查询数据库或其他数据源,获取渠道和机构的相关信息。
4. 根据渠道和机构的相关信息,计算分摊费用,并将计算结果返回给调用方。
下面是一个示例代码:
```java
@RestController
@RequestMapping("/calculate")
public class CostController {
@Autowired
private CostService costService;
@GetMapping("/cost")
public double calculateCost(@RequestParam("channel") String channel, @RequestParam("organization") String organization) {
// 查询渠道和机构信息
Channel channelInfo = costService.getChannel(channel);
Organization orgInfo = costService.getOrganization(organization);
// 计算分摊费用
double cost = costService.calculateCost(channelInfo, orgInfo);
return cost;
}
}
```
在上面的示例代码中,我们使用了SpringBoot的注解,将该类声明为一个RESTful API的Controller。在calculateCost方法中,我们使用@RequestParam注解获取外部传递的渠道和机构信息,并调用CostService中的方法查询渠道和机构信息,并计算分摊费用。
需要注意的是,我们在代码中使用了@Autowired注解自动注入了CostService,该服务类中需要实现具体的计算逻辑和数据查询操作。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)