D
Dmitri Islentyev
Hello everyone!
Please consider the following code:
class Base {
public:
Base(int x);
virtual int foo() { return 17; }
};
class Derived: public Base {
Derived(int x);
int foo() { return 23; }
};
class Maker {
static Base CreateBase(bool whether)
{
if(whether)
return Base(0);
else
return Derived(1);
}
};
// client
Base b=Maker.CreateBase(1);
b.foo(); // returns 17
Base d=Maker.CreateBase(0);
d.foo(); // returns 17
There`s no vtable in value variables, the solution is to use pointers.
But what`s the method to delete returned pointers, if, for example,
I return a cursor class from operator [] just for one function call
from returned cursor instance?
Please consider the following code:
class Base {
public:
Base(int x);
virtual int foo() { return 17; }
};
class Derived: public Base {
Derived(int x);
int foo() { return 23; }
};
class Maker {
static Base CreateBase(bool whether)
{
if(whether)
return Base(0);
else
return Derived(1);
}
};
// client
Base b=Maker.CreateBase(1);
b.foo(); // returns 17
Base d=Maker.CreateBase(0);
d.foo(); // returns 17
There`s no vtable in value variables, the solution is to use pointers.
But what`s the method to delete returned pointers, if, for example,
I return a cursor class from operator [] just for one function call
from returned cursor instance?