I
ironfelix
Hi there,
Simple program ( below ) provides to array destructor in G++ second
argument equal to 7 and in Visual C++ second argument, equal to 1. I
think it is a bug in Visual C++. Any comments ?
// copyConstructor.cpp : Defines the entry point for the console
application.
//
#include<stdlib.h>
#include<stdio.h>
class A {
public:
void * A:perator new(size_t size); /* object's creator */
void * A:perator new[](size_t size); /* array of objects creator */
void A:perator delete(void *mem, size_t size); /* object's
destroyer */
void A:perator delete[](void *mem, size_t size); /* array of
objects destroyer */
A::A(); /* constructor */
A::A(const A &src); /* copy constructor */
A &A:perator = ( A &a); /* Assign operator */
A::~A(); /* destructor */
};
void * A:perator new(size_t size){
void *mem;
mem= (void *) malloc( size);
printf("Create dynamic object %p size %d\n", mem, (int) size);
return mem;
};
void * A:perator new[](size_t size){
void *mem;
mem= (void *) malloc( size);
printf("Create dynamic array of objects %p size %d\n", mem, (int)
size);
return mem;
};
void A:perator delete(void *mem, size_t size){
printf("Destroy object %p size %d\n", mem, (int) size);
(void) free((void *)mem);
}
void A:perator delete[](void *mem, size_t size){
printf("Destroy of array of objects %p size %d\n", mem, (int) size);
(void) free((void *)mem);
}
A::A(){
printf("Constructor %p\n", this);
};
A::A(const A &src){
printf("Copy constructor src: %p dst: %p\n", &src, this);
};
A & A:perator = ( A &a){
printf("Assign operator src %p dst %p\n", &a, this);
return a;
};
A::~A(){
printf("Destructor... %p\n", this );
};
static void f(A a){
printf("F.... %p\n", &a);
}
int main(int argc, char ** argv)
{
A *zu;
zu= new A[3];
delete[]zu;
printf("Game over, man\n");
return 0;
}
Simple program ( below ) provides to array destructor in G++ second
argument equal to 7 and in Visual C++ second argument, equal to 1. I
think it is a bug in Visual C++. Any comments ?
// copyConstructor.cpp : Defines the entry point for the console
application.
//
#include<stdlib.h>
#include<stdio.h>
class A {
public:
void * A:perator new(size_t size); /* object's creator */
void * A:perator new[](size_t size); /* array of objects creator */
void A:perator delete(void *mem, size_t size); /* object's
destroyer */
void A:perator delete[](void *mem, size_t size); /* array of
objects destroyer */
A::A(); /* constructor */
A::A(const A &src); /* copy constructor */
A &A:perator = ( A &a); /* Assign operator */
A::~A(); /* destructor */
};
void * A:perator new(size_t size){
void *mem;
mem= (void *) malloc( size);
printf("Create dynamic object %p size %d\n", mem, (int) size);
return mem;
};
void * A:perator new[](size_t size){
void *mem;
mem= (void *) malloc( size);
printf("Create dynamic array of objects %p size %d\n", mem, (int)
size);
return mem;
};
void A:perator delete(void *mem, size_t size){
printf("Destroy object %p size %d\n", mem, (int) size);
(void) free((void *)mem);
}
void A:perator delete[](void *mem, size_t size){
printf("Destroy of array of objects %p size %d\n", mem, (int) size);
(void) free((void *)mem);
}
A::A(){
printf("Constructor %p\n", this);
};
A::A(const A &src){
printf("Copy constructor src: %p dst: %p\n", &src, this);
};
A & A:perator = ( A &a){
printf("Assign operator src %p dst %p\n", &a, this);
return a;
};
A::~A(){
printf("Destructor... %p\n", this );
};
static void f(A a){
printf("F.... %p\n", &a);
}
int main(int argc, char ** argv)
{
A *zu;
zu= new A[3];
delete[]zu;
printf("Game over, man\n");
return 0;
}