You can't use sizeof because i and c are dynamically sized and therefore not known until runtime, so you would have to write your own custom size function.

If i and c are statically sized then you can use sizeof.

Code:
class A
{
private:
	int ilen,clen;
	int *i;
	char *c;

public:
	A(int ni,int nc);
	int size();
};

A::A(int ni,int nc)
{
	ilen=ni;
	clen=nc;
	i = new int[ilen];
	c = new char[clen];
}

int A::size()
{
	return sizeof(*this)+ilen*sizeof(int)+clen*sizeof(char);
}

class B
{
private:
	int i[10];
	char c[10];

public:
	B(){};
};

void go4e_15856()
{
	A a1(10,10), a2(20,20);
	printf("Size of a1,a2 is %d,%d\n",a1.size(),a2.size());

	B b1;
	printf("Size of b1 is %d\n",sizeof(b1));
}