hi all, I get a compile time error when I tried to assign A*
to A[]. I get the error in DEV C++ , mingw ,error
"incompatible type assignment"
should I have to use dirty pointers for this ?
#include <iostream>
class A
{
public:
int a ;
int b ;
static int c ;
/* default constructor.
*/
A()
{
c++ ;
std::cout << " A() is called " << " and a is " << c << std::endl;
}
/* assignment operator
*/
const A& operator = ( const A& a )
{
std::cout << " assiment operator is called " << std::endl ;
}
/* The destructor
*/
~A()
{
std::cout << " ~A() is called " << std::endl ;
}
private:
};
int A::c=0 ;
class B
{
public:
A a[];
/*
default constructor
*/
B()
{
std::cout << " B() is called " << std::endl ;
a = new A[200];
}
/*
THe destructor of the B
*/
~B()
{
std::cout << " ~B() is called " << std::endl ;
}
};
int main(int argc, char *argv[])
{
B b ;
delete &b;
std::getchar() ;
return EXIT_SUCCESS;
}