I am hours trying to figurate out where is the problem, but it seems so strange.
I rewrote my problem in an easier way to understand.
When it gets to the line where it says delete, the debbug makes a breakpoint.
Ps. Intresting to note that, if we take int b1 and move it to Base2 it works.
Base1:
#pragma once
class Base1
{
public:
Base1();
~Base1();
int b1;
};
Base2.h:
#pragma once
#include <iostream>
#include <vector>
class Derived;
class Base2
{
public:
Base2();
~Base2();
std::vector <std::vector <Base2*>> vec;
void doSomething(Derived& d);
};
Base2.cpp:
#include "Base2.h"
#include "Derived.h"
Base2::Base2()
{
//the numbers 1 and 5 does not really metter
vec.resize(1);
vec[0].resize(5);
}
Base2::~Base2()
{
}
void Base2::doSomething(Derived& d)
{
vec[0][d.b1] = new Derived();
delete vec[0][d.b1];
}
Derived:
#pragma once
#include "Base1.h"
#include "Base2.h"
class Derived : public Base1, public Base2
{
public:
Derived();
~Derived();
};
main:
#include <iostream>
#include "Derived.h"
int main()
{
Derived d;
d.b1 = 1;
d.doSomething(d);
}