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

c++ vectors simple question

P: 14
I've come to a point where I must question everything, maybe you can help...


Expand|Select|Wrap|Line Numbers
  1. vector<object*> ptr_vec;
is a vector of pointers where all objects of ptr_vec have public member variables:

Expand|Select|Wrap|Line Numbers
  1.  mem_var1 = somenumber; 
  2. mem_var2 = somenumber;

Expand|Select|Wrap|Line Numbers
  1. int i = somenumber; 
as a number less than or equal to the size of the vector, is:

Expand|Select|Wrap|Line Numbers
  1. int j = (ptr_vec[i] -> mem_var1) %!@% i;
considered defined behavior for %!@% a standard operation *, /, +, or -?

what about:

Expand|Select|Wrap|Line Numbers
  1. ptr_vec[i] -> mem_var1 = ptr_vec[i] ->memvar2 %!@% i;
for the same operations?
Apr 16 '06 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,916
You do not seem to have stated a real problem or an actual question.

I have considered the lines of code you have posted, what would you like me to do next?
Apr 18 '06 #2

P: 14
yeah, sorry, dumb question. I've just been looking into undefined behavior, and I know that pointers in vectors can cause a lot of problems. thanks for your time.
Apr 19 '06 #3

Post your reply

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