what will be the size of the class & Object ?

M

Matrixinline

Hi All,
I know I am asking a dumb question but can you Please let me know
what should be the size of the class & its object? will the Objects
size will be different?

class Product
{
string m_sItem;
string m_sIteFile;
char m_oName[128]
map<string, string> m_oSubItem;
map<string, string> m_oLocalItem;
};

Product oProduct;


sizeof(oProduct)==sizeof(Product) ?? is this will be true?
If I calculate sizeof(Product) will this give me different anwser on
different system?


Thanks
Anup
 
Y

yanlinlin

Hi All,
I know I am asking a dumb question but can you Please let me know
what should be the size of the class & its object? will the Objects
size will be different?

class Product
{
string m_sItem;
string m_sIteFile;
char m_oName[128]
map<string, string> m_oSubItem;
map<string, string> m_oLocalItem;

};

Product oProduct;

sizeof(oProduct)==sizeof(Product) ?? is this will be true? yes.

If I calculate sizeof(Product) will this give me different anwser on
different system? maybe.


Thanks
Anup
 
E

Erik Wikström

Hi All,
I know I am asking a dumb question but can you Please let me know
what should be the size of the class & its object? will the Objects
size will be different?

class Product
{
string m_sItem;
string m_sIteFile;
char m_oName[128]
map<string, string> m_oSubItem;
map<string, string> m_oLocalItem;
};

Product oProduct;


sizeof(oProduct)==sizeof(Product) ?? is this will be true?
Yes.

If I calculate sizeof(Product) will this give me different anwser on
different system?

Actually, you do not have to use a different system, just changing some
compiler options might suffice.
 
S

Salt_Peter

class Product
{
string m_sItem;
string m_sIteFile;
char m_oName[128]

// ; missing, compilation error
map<string, string> m_oSubItem;

and what is this type?
map<string, string> m_oLocalItem;

Its a sequenced container, this std::map stores std::string pairs.
These pairs are ordered upon insertion using a default predicate
(less< key >)
or any comparator you choose to provide.

of course, you need
#include <map>

std::map< key, value_type > m;

You might consider reviewing std::set, std::multiset as well as
std::multimap too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top