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 ...
随机推荐
- Vue2.0学习——axios用法详解
功能特性 在浏览器中发送 XMLHttpRequests 请求 在 node.js 中发送 http请求 支持 Promise API 拦截请求和响应 转换请求和响应数据 自动转换 JSON 数据 客 ...
- Vue 组件(上)转载
一.定义 组件:应用界面上一个个的区块. 自定义的HTML元素. 二.创建和注册 Vue.extend() 扩展,创建组件构造器 Vue.component()注册组件,2个参数,1为标签,2是组件构 ...
- .bat批处理添加Python任务
一.常用命令含义 例一.多进程python 任务 -- start 命令 @echo offstart python C:\Users\ntitled\n\update_restt\test_ba ...
- P1025 数的划分 dfs dp
题目描述 将整数nn分成kk份,且每份不能为空,任意两个方案不相同(不考虑顺序). 例如:n=7n=7,k=3k=3,下面三种分法被认为是相同的. 1,1,51,1,5;1,5,11,5,1;5,1, ...
- 爬虫3 requests之json 把json数据转化为字典
#json 将json数据转化为字典,方便操作数据 res = requests.get('http://httpbin.org/get') print(res.json()) #res.json() ...
- 队列queue实现线程的消费者和生产者
import threading import queue import random import time qq = queue.Queue(4) #实例化一个队列,因为是一个进程的线程,所以共资 ...
- Centos7服务器中通过编译源码安装MySQL
基于在Centos7服务器上使用 yum 安装MySQL5.7到默认路径 在修改文件存储位置的时候,折腾了一番没有将成功将datadir修改为我想要的位置 我决定再尝试一下通过编译源码来自定义安装: ...
- [ 严重 ] my网SQL注入
RANK 80 金币 100 数据包 POST maoyan.com/sendapp HTTP/1.1Host: xxx.maoyan.comUser-Agent: Mozilla/5.0 ( ...
- 004.Ansible Ad-Hoc命令集
一 Ad-Hoc使用场景 Ad-Hoc更倾向于解决简单.临时性任务. 1.1 Ad-Hoc基础命令 基本语法: 1 ansible <host-pattern> [options] < ...
- webpack+vue+es6+postcss
本篇文章仿照vue-cli生成的项目结构,自己重新搭建目录,写一个小demo进一步巩固单文件组件的知识,并且学习中间件.一.要解决的问题1.如果把webpack.config.js放进build文件夹 ...