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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:53:01+00:00 2026-06-06T21:53:01+00:00

My understanding is typedef acts as a synonym for a type, or can be

  • 0

My understanding is typedef acts as a synonym for a type, or can be used as an alias for a particular type. Also, the simplified codes below built perfectly. The question here is if I change the second line in the main function to :

Array<int>::ArrayIter<T> pa = a.begin(); // substituting back the typedef  “iterator” to its original form of ArrayIter<T>.

I get the following error message during compilation:

“ArrayIter” is not a member of “Array”

But the codes compiled perfectly using the “typedef” (iterator) notation. Why is “iterator” and ArrayIter suddenly not synonymous any more:

Reference codes below:

template<class T> class ArrayIter {
public:
ArrayIter(T* p) : m_p(p) {
}

private:
T* m_p;
};

template<class T> class Array {

public:
  Array(int size) throw (const char*) {
    if ( size > 0 ) {
       m_p = new T[size];
       m_size = size;
    } else {
   throw "Array: invalid array dimension";
}
  }

  // typedef and methods to support the new iterator for this class
  typedef ArrayIter<T> iterator;

  ArrayIter<T> begin() {
  return ArrayIter<T>(m_p);
  }

private:
  T* m_p;
  int m_size;
};


int main(int argc, char* argv[]) {

  Array<int> a(10);
  Array<int>::iterator pa = a.begin();

 return 0;
}
  • 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-06-06T21:53:03+00:00Added an answer on June 6, 2026 at 9:53 pm

    As the error says, ArrayIter is not a member of Array: it’s a separate class, declared in the surrounding namespace. Therefore, Array<int>::ArrayIter<T> is invalid, and should just be ArrayIter<int>.

    iterator is a member of Array, so Array<int>::iterator is valid, and is an alias for ArrayIter<int>.

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

Sidebar

Related Questions

It is my understanding that either a declaration or typedef of a specialization ought
So I'm using a boost graph of the following type: typedef boost::adjacency_list<boost::listS, boost::vecS, boost:directedS,
So, my current understanding of enum is that I can use it to make
i need to know how can i resolve Unions and Type** (e.g. int**) with
I am having hard time understanding typedef pattern for arrays. typedef char Char10[10]; void
I'm trying to understand the code below, and I'm having some trouble understanding why
My understanding of winmm.dll is it can change the length of the ticks. In
Due to my feeble understanding of allocating type memory to pointers, the following causes
I need some assistance understanding how variables of a typedef work with structs /*This
New to ios. Let me correct if my understanding is wrong?. typedef void (^someString)

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.