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 ...
随机推荐
- POJ1469 COURSES 二分图匹配 匈牙利算法
原文链接http://www.cnblogs.com/zhouzhendong/p/8232649.html 题目传送门 - POJ1469 题意概括 在一个大矩阵中,有一些障碍点. 现在让你用1*2 ...
- Hibernate中报错org.hibernate.HibernateException: No CurrentSessionContext configured!
报错信息如下: 解决方法: 问题原因是getCurrentSession()出现了问题 在hibernate.cfg.xml(hibernate的核心配置文件)文件中加入下列代码: <prope ...
- SpringMVC(二六) SpringMVC配置文件中使用mvc:view-controller标签
在springmvc中使用mvc:view-controller标签直接将访问url和视图进行映射,而无需要通过控制器. 参考springmvc.xml内容: <?xml version=&qu ...
- 解决在VUE中绑定WebSocket事件无法传值的问题
this.webSocket.onerror =(env)=>{ this.onError(env) }; https://jsfiddle.net/dko6g9a4/1/
- [MongoDB] MongoDB管理:使用killOp干掉Long Running Operation
http://www.mongoing.com/archives/2563 MongoDB提供了killOp请求,用于干掉运行时间很长的请求,killOp通常需要与currentOp组合起来使用:先根 ...
- (Android数据传递)Intent消息传递机制 “Intent”“数据传递”
Intent类的继承关系: 需要注意的是,该类实现了Parcelable(用于数据传递)和Cloneable接口. Intent是一种(系统级别的)消息传递机制,可以在应用程序内使用,也可以在应用 ...
- 潭州课堂25班:Ph201805201 django 项目 第二十九课 docker实例,文件下载前后台实现 (课堂笔记)
docker 实例 :wq!保存退出 放入一个 html 文件 权限不够,加 sudo 查看本地仓库的 image 运行 docker -- name,后跟个运行名, -p 物理机端口映射到容器端口, ...
- 全国青少年信息学奥林匹克分区联赛(N)竞赛大纲
全国青少年信息学(计算机)奥林匹克分区联赛竞赛大纲 一.初赛内容与要求:(#表示普及组不涉及,以下同) 计算机的基本发展 诞生与发展 特点 在现代社会中的应用 计算机系统的基本组成 计算机的工作原理# ...
- python字符串与列表的相互转换
学习内容: 1.字符串转列表 2.列表转字符串 1. 字符串转列表 s ='hello python !'li = s.split(' ') #注意:引号内有空格print (li)输出:['hell ...
- 回文检测 [USACO Training Section 1.3]
题目描述 据说如果你给无限只母牛和无限台巨型便携式电脑(有非常大的键盘),那么母牛们会制造出世上最棒的回文.你的工作就是去寻找这些牛制造的奇观(最棒的回文). 在寻找回文时不用理睬那些标点符号.空格( ...