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 3843408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:56:02+00:00 2026-05-19T15:56:02+00:00

The code is as follows template<class T> class arrayList { public: // constructor, copy

  • 0

The code is as follows

template<class T>
class arrayList {
public:
    // constructor, copy constructor and destructor
    arrayList(int initialCapacity = 10);
    arrayList(const arrayList<T>&);
    ~arrayList() {
        delete[] element;
    }

    class seamlessPointer;
    seamlessPointer begin() {
        return seamlessPointer(element);
    }
    seamlessPointer end() {
        return seamlessPointer(element + listSize);
    }

    // iterator for arrayList
      class iterator
      {
         public:
            // typedefs required by C++ for a bidirectional iterator
            typedef bidirectional_iterator_tag iterator_category;
            typedef T value_type;
            typedef ptrdiff_t difference_type;
            typedef T* pointer;
            typedef T& reference;

            // constructor
            iterator(T* thePosition = 0) {position = thePosition;}

            // dereferencing operators
            T& operator*() const {return *position;}
            T* operator->() const {return position;}

            // increment
            iterator& operator++();
                      {++position; return *this;}
            iterator operator++(int);

            // decrement
            iterator& operator--();
            iterator operator--(int) ;

            // equality testing
            bool operator!=(const iterator right) ;
            bool operator==(const iterator right) ;
         protected:
            T* position;
      };  // end of iterator class

        class seamlessPointer: public arrayList<T>::iterator {

        public:
            typedef random_access_iterator_tag iterator_category;
            typedef T value_type;
            typedef ptrdiff_t difference_type;
            typedef T* pointer;
            typedef T& reference;
            // constructor
            seamlessPointer(T *thePosition);
            seamlessPointer(const seamlessPointer & rhs);
            //arithmetic operators
            seamlessPointer operator+(int n) ;

            seamlessPointer operator-(int n) ;
    };

protected:
    T* element; // 1D array to hold list elements
    int arrayLength; // capacity of the 1D array
    int listSize; // number of elements in list
};

c:\wascana\mingw\bin\../lib/gcc/mingw32/4.5.0/include/c++/bits/stl_algo.h:5250:4: error: no match for 'operator-' in '__last - __first'
  • 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-19T15:56:02+00:00Added an answer on May 19, 2026 at 3:56 pm

    Looking over your code it appears that you’ve got the right kinds of ideas by including those typedefs with your own iterator implementation. However, why go to all the trouble in the first place when something else could do it for you? Have you looked at iterator_traits or the standard iterator? They just add typedefs to your code which will aid you in developing new iterator types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, here is the code and then the discussion follows: public class FlatArrayList {
So, simple procedure, calculate a factorial number. Code is as follows. int calcFactorial(int num)
Essentially, the situation is as follows: I have a class template (using one template
This cites for_each as follows: template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last,
When I need code template, I can use Python as follows. templateString = %s
What advantage, if any, is provided by formatting C code as follows: while(lock_file(lockdir)==0) {
I've written a rails app that follows the regular directory structure (model code in
I have a template class like this: template<T> class MyClass { T* data; }
I have a template class that is only valid for couple of template parameters:
I have a template class, C_Foo<T>, which is specialised in a number of ways.

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.