Hello!
I'm quite new in C++ and even if i have some solid C experience, if find some things confusing.
Here's my problem:
1. I have a list<column> container in my program.
2. I want to insert something.
3. The STL list.insert requires an iterator parameter to be passed to it.
4. I want to insert an element at a specified index.
5. I don't assume that the index is within the range of the list, so when i try to get the iterator at the specified position, i would like to return some NULL pointer if the index is out of range. However, you cannot assign a NULL pointer to a reference (i guess that's because the refs are automatically dereferenced).
The problem is that i dont' want to set any flags telling me that something went wrong, i just want to know if the reference returned is valid or not.
So, i have 2 questions:
Q1: How do i use references in order to simulate some NULL pointer?
Q2: How do i use an iterator to return a POINTER to the object, instead a reference to it?
I hope i'm not deeeeeply confuzed here... But if i am, i would appreciate greatly any help!
Thanks
I'm quite new in C++ and even if i have some solid C experience, if find some things confusing.
Here's my problem:
1. I have a list<column> container in my program.
2. I want to insert something.
3. The STL list.insert requires an iterator parameter to be passed to it.
4. I want to insert an element at a specified index.
5. I don't assume that the index is within the range of the list, so when i try to get the iterator at the specified position, i would like to return some NULL pointer if the index is out of range. However, you cannot assign a NULL pointer to a reference (i guess that's because the refs are automatically dereferenced).
The problem is that i dont' want to set any flags telling me that something went wrong, i just want to know if the reference returned is valid or not.
So, i have 2 questions:
Q1: How do i use references in order to simulate some NULL pointer?
Q2: How do i use an iterator to return a POINTER to the object, instead a reference to it?
I hope i'm not deeeeeply confuzed here... But if i am, i would appreciate greatly any help!
Thanks