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 ...
随机推荐
- HtmlTestRunner
1.一般生成报告时,会使用时间来作为报告名称的一部分,引入time这个第三方,使用以下方式格式化当前时间 下面运行最终结果:2019-03-29-14_29_18------>年-月-日-时-分 ...
- 如何在不使用try语句的情况下查看文件是否存在
如果你要确定文件存在的话然后做些什么,那么使用try是最好不过的 如果您不打算立即打开文件,则可以使用os.path.isfile检查文件 如果path是现有常规文件,则返回true.对于相同的路径, ...
- 页面滚动到指定class样式位置
var winTop =$(window).scrollTop(); var top = document.getElementsByClassName('is-danger')[0].getBoun ...
- 问题 L: An Invisible Hand - (2018年第二阶段个人训练赛第三场)
题目描述 There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant ...
- 打印星星 - Python
打印星星是经典面试题目,考察流程控制中的循环和条件.本文对相关方法进行总结. 到的方法只要有(1)嵌套循环(2)center(3)format(^)(4)字符串乘法 # -*- coding:utf- ...
- Certbot让网站拥有免费https证书
网站使用http协议,在chrome浏览器中总是报不安全,看着就让人不爽,自己建的网站,不安全总是会让自己心慌慌.看到有头有脸的网站都是https开头,心中自然也想装逼一把,让自己的网站高端大气上档次 ...
- 自己总结的C#编码规范--3.特定场景下的命名最佳实践
特定场景下的命名最佳实践 命名空间 要使用PascalCasing,并用点号来分隔名字空间中的各个部分. 如Microsof.Office.PowerPoint 要用公司名作为命名空间的前缀,这样就可 ...
- 2046 ACM 数学
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2046 思维:与之前有两道题目相似,n可以由n-1和n-2递推过来.f(n)=f(n-1)*1+f(n-2) ...
- python反转列表的三种方式
1.内建函数reversed() li =[1, 2, 3, 4, 5, 6] a = list(reversed(li)) print (a) 注意:reversed()函数返回的是一个迭代器,而不 ...
- [P1034][NOIP2001]一元三次方程求解 (二分)
二分 #include<bits/stdc++.h> using namespace std; double a,b,c,d; double fc(double x) { )+b*pow( ...