From: Walid R. <wr...@em...> - 2012-11-17 16:15:49
|
Hello, I have some code that compile and work fine in gcc 4.6.2 (without tne new keyword "override" ) but in version 4.7.2 it complie generate access violation runtime So, i need some help, thank you very much: #include <iostream> using namespace std; struct Entity { //~Entity() = default; //work fine ~Entity() {} //when i specified my destructor this compile but generate runtime access viloation }; template<typename T> struct IRepository { virtual T g() = 0; }; struct OtherInterface{ virtual void y() = 0; }; struct IEntityRepository : public virtual IRepository<Entity>{ }; template<typename T> struct RepositoryBase : public virtual IRepository<T>, public OtherInterface{ virtual void y() override { cout << "y() override called" << endl; } }; template<typename T> struct DataRepository : public RepositoryBase<T>{ virtual T f() { cout << "f() called" << endl; this->y(); T t; return t; } T g() override { cout << "g() override called" << endl; ////when i specified my destructor for class Entity this compile but generate runtime access viloation here : on this: probably problem with vptr return this->f(); } }; struct EffectiveEntityRepository : public DataRepository<Entity>, public IEntityRepository{ }; int main() { IEntityRepository* var = new EffectiveEntityRepository(); var->g(); return 1; } |