Code:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char buf[8];
int *x = new(&buf[0])int;
int *y = new(&buf[0]+4)int;
delete x;
delete y;
}
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char buf[8];
int *x = new(&buf[0])int;
int *y = new(&buf[0]+4)int;
delete x;
delete y;
}
Dakle, da li se problem pri brisanju x odnosno y promenljive javlja zato što bafer buf nije na heap-u? Jer ako bude, onda nema problema...