std::vector push_back报错Access violation
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <vector>#include <string>#include <iostream>struct Person{ std::string name; int age; std::string bank_ac_no; Person(const std::string& name, int years, const std::string& ac_no) : name(name), age(years), bank_ac_no(ac_no) {} Person() : name(""), age(0), bank_ac_no(""){}};int main(int argc, char *argv[]){ struct Person p1 = { "A Smith", 71, "5702750" }; std::vector<Person> people1(0); people1.push_back(p1); return 0;} |
运行的时候在push_back那一句报如下的错误:
Unhandled exception at 0x50C031CA (msvcr120d.dll) in Test15.exe: 0xC0000005: Access violation reading location 0x391F9350.
试了一下,如果不是push_back自定义的struct,而是push_back一个内置类型(比如int,string)就不会报错.
到底是怎么回事那? 请指教. 谢谢
[问题补充] 新建了一个项目, 把上面的代码拷贝过去,就没有问题. 检查了一下新项目和现在的项目,配置是一模一样的.
[答案]
原来我项目中的其他文件中也定义了一个struct Person, 把其他的一个struct改一下名字就好了.
std::vector push_back报错Access violation的更多相关文章
- cout显示Mat类对象报错Access Violation
AV(Access Violation)错误:非法访问. image_match.exe 中的 0x0000002a 处有未经处理的异常: 0xC0000005: Access violation 程 ...
- vector push_back报错
场景:定义了一个结构体,包含一个vector的成员变量,在给这个vTQ push_back数据的时候报错. typedef struct tag_TQInfo { int iTime; int iMa ...
- 网站报错Access denied for user 'root'@'localhost' -问题排查续
网站报错Access denied for user 'root'@'localhost' (using password: YES) 每次的挽救办法就是: /etc/init.d/mysqld st ...
- 报错: Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library
报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C ...
- 008-MySQL报错-Access denied for user 'root'@'localhost' (using password: NO)
1.新安装的mysql报错 MySQL报错-Access denied for user 'root'@'localhost' (using password: NO) 解决方案 1.先停掉原来的服务 ...
- vs.Debug.vector迭代器报错(_ITERATOR_DEBUG_LEVEL)
1.vs2017.Win7x64 std::vector<ULONG>,在 使用 *iter 取某个 ULONG时 报错,release不报错,报错信息: ZC:具体原理不明,暂时的解决方 ...
- PL/SQL插入数据报错:Access violation at address 00413A81 in module 'plsqldev.exe'. Read of address 00000000
前言 今天同事在使用plsql给oracl数据库插入记录时报错:Access violation at address 00413A81 in module 'plsqldev.exe'. Read ...
- MySQL登录报错"Access denied for user 'root'@'localhost' (using password: YES)"
最近登录MySQL时候总报错: # mysql -uroot -p Enter password: ERROR (): Access denied for user 'root'@'localhost ...
- 接口调用 读取图片报错 Access to the path '' is denied.解决方案
调用接口 读取服务器上 图片 报错: Server was unable to process request. ---> Access to the path '图片路径' is denied ...
随机推荐
- 00-JAVA语法基础--动手动脑
1.运行EnumTest.java,并分析结果,得出结论. 其源代码以及运行结果截图如下: 枚举类型的常量以字符串的形式顺序储.源代码中s和t不是原始数据类型.getCLass():取得当前对象所属的 ...
- 打印星星 - Python
打印星星是经典面试题目,考察流程控制中的循环和条件.本文对相关方法进行总结. 到的方法只要有(1)嵌套循环(2)center(3)format(^)(4)字符串乘法 # -*- coding:utf- ...
- 001.Linux开机启动过程
相关Linux启动过程解析,此作为通用启动参考:
- JDBC概述
什么是持久化(persistence):持久化(persistence):把数据保存到可掉电式存储设备中以供之后使用.大多数情况下,特别是企业级应用,数据持久化意味着将内存中的数据保存到硬盘上加以”固 ...
- C# 的Chart
Axis Label 横纵坐标的文字 (比如 0 20 40 ....) Axis Title 横纵坐标的代表什么(比如 Y Axis Title) Chart Area 图标所在位置 Chart P ...
- VsVim的快捷键
VsVim - Shortcut Key (快捷键) Enable / Disable 还可以通过 Ctrl+Shift+F12 在 Visual Studio 中实现 Enable / Disabl ...
- 使用open live writer客户端写博客zz
下载地址 http://openlivewriter.org/ 具体配置步骤 选择日志服务类型为"其它日志类型" 添加日志账户: 安装后的优化配置 获取博客园主题 安装完OLW(o ...
- JavaScript基础笔记(十四)最佳实践
最佳实践 一)松散耦合 1.解耦HTML/JavaScript: 1)避免html种使用js 2)避免js种创建html 2.解耦CSS/JS 操作类 3.解耦应用逻辑和事件处理 以下是要牢记的应用和 ...
- IDEA+Maven:cannot download sources
把IDEA的maven换成maven2
- 三十分钟学完Vue
基础知识: vue的生命周期: beforeCreate/created. beforeMount/mounted. beforeUpdate/updated. beforeDestory/desto ...