Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:13:08+00:00 2026-05-30T00:13:08+00:00

I am currently working on creating a header file that acts like the standard

  • 0

I am currently working on creating a header file that acts like the standard library. I am in the progress of implemeing .end() for my linked list. In my cpp file I have an integer pointer which is expected to recieve the value of the .end() like

int* itrend;
itrend = ca.end();

ca is just an instance of my object in my header file.
In my hpp file, I have a list iterator going to my listofvalues.end(). I would like to return the .end() value like

int* end() 
{
    std::list<value_type>::iterator i = listOfValues.end();
    return (&*i);

}

My “List of values” is just a list holding several ints. eg

[1,2,3,4,5,6,7,8,9]

In my hpp file, I have a list iterator going to my listofvalues.end(). I would like to return the .end() value (which returns a list iterator); now this posess a problem that it returns the list iterator when I want to have an integer pointer. I have tried to deference it and take the address by using &* and this will give an error saying “List Iterator Not Dereferencable”. I know it’s because I’m trying to get the element after the last value, but that is exactly what I need to return, since I am trying to re-implement the linked list .end() method.

Does anyone know how I can have an integer pointer point to the List.end()?

Any assistance is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:13:09+00:00Added an answer on May 30, 2026 at 12:13 am

    To implement begin() and end() in a style similar to STL return iterators, not pointers:

    template <typename value_type>
    class my_list
    {
    public:
        typedef std::list<value_type>::iterator iterator;
        typedef std::list<value_type>::const_iterator const_iterator;
    
        iterator begin() { return listofValues.begin(); }
        const_iterator begin() const { return listofValues.begin(); }
    
    
        iterator end() { return listofValues.end(); }
        const_iterator end() const { return listofValues.end(); }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on creating a new C# project that needs to interact with
I'm currently working with Sharepoint 2010 and Sharepoint API on creating a document library
Am currently working on an application that requires users to submit posts and comments
I'm currently working on creating a custom connection provider for HNibernate very similar to
I'm creating a game, and am currently working on the Inventory system for it.
I'm creating an Android application (Android 2.3.3) that has a header, a footer and
I'm programatically creating a custom section header for a table that has a width
I am currently working on creating an overloaded function for the == operator. I
I'm currently working on creating a private messaging system, (PHP/MySQL) in which users can
Im currently working on creating some appwidgets for my application; one of those is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.