By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

Calculating object size

P: 1
Hi friends,
Is there any way to find out the size of an object in c++.

Bala
Sep 28 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
use the sizeof operator.

But a little caution is required

class A
{
...
}

A a;
A *pa;

sizeof a == the size of the object a

sizeof pa == the size of a pointer that points to A (probably 2 or 4 bytes)

sizeof *pa == sizeof a == sizeof(A)
Sep 28 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.