SImple question about structure and linked list

J

John

Thanks.
If I define the following structure,
typedef struct{
vector<int> v;
int ID;
double time;
}node;

What should be the size of the structure node?
If I insert elements into vector v, will the size of structure node increase?

John.
 
D

Daniel T.

Thanks.
If I define the following structure,
typedef struct{
vector<int> v;
int ID;
double time;
}node;

What should be the size of the structure node?

int find_out() {
cout << sizeof( node );
}

Note however, that the size may be different on different machines.

If I insert elements into vector v, will the size of structure node increase?

int lets_see() {
node n;
cout << sizeof( n ) << endl;
for (int x = 0; x < 1000; ++x ) {
n.v.push_back( x );
}
cout << sizeof( n ) << endl;
}

What is the output, are the two number the same or different?
 

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

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,462
Latest member
ChanaLipsc

Latest Threads

Top