jeudi 14 février 2019

Program crash when it running "exited with code -1073741819"

Good afternoon, I have a problem with my program, it crash when running. I used this code for create new instance class in vector.

main.cpp :

#include <QCoreApplication>
#include <iostream>
#include <vector> //header file where std::vector is defined
#include <myclass.h>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    for(unsigned long long i = 0 ; i<=10;i++){
        std::vector<MyClass>  arr(i, MyClass(10,20+i));
        std::cout << arr[i].ggg;
    }

    return a.exec();
}

myclass.cpp:

#include "myclass.h"

MyClass::MyClass(){}
MyClass::MyClass(unsigned long long g, unsigned long long gg){
    ggg = gg;
}

myclass.h:

#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass
{
public:
    MyClass();
    MyClass(unsigned long long g, unsigned long long gg);
    unsigned long long ggg;
};

#endif // MYCLASS_H

I have this error in console : exited with code -1073741819 I do not know where the issue, I am a beginner in C ++. Thank you in advance for your help,

Aucun commentaire:

Enregistrer un commentaire