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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:06:00+00:00 2026-05-13T22:06:00+00:00

I have the following function defined inside my linked list class. The declaration in

  • 0

I have the following function defined inside my linked list class. The declaration in the header file looks like this:

template <typename T>
class RingBuffer
{
  ...//stuff
  static BLink * NewLink (const T&); // allocator
};

BLink is a “link” class within the RingBuffer class. The following implementation code:

template <typename T>
RingBuffer<T>::BLink * RingBuffer<T>::NewLink( const T& t ) // this is line 114
{
  // create a new link in linked list
  ....
  ....
}

Is giving me this compile error:

./ringbuff.cpp:114: error: expected constructor, destructor, or type conversion before â*â token

I am stumped as to why it it needs an expected constructor, destructor, or type conversion before the return value.

  • 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-13T22:06:01+00:00Added an answer on May 13, 2026 at 10:06 pm

    The problem here is that you are referring to a nested dependent type name (i.e. BLink is nested inside RingBuffer which is dependent on a template parameter)

    You need to help your compiler a little in this case by stating that RingBuffer<T>::BLink is an actual type name. You do this by using the typename keyword.

    template <typename T>
    typename RingBuffer<T>::BLink * RingBuffer<T>::NewLink(const T& t)
    {
      // ...
    }
    

    Explanation:

    The compiler cannot know if RingBuffer<T>::BLink is a type name or a static member until the template parameter T is known. When the compiler parses your function template T is not known and the rule to solve the ambiguity is to default to “this is not a type name”.

    Another short example (blatantly copied from Scott Meyers’ Effective C++):

    template<typename C>
    void print2nd(const C& container)
    {
      C::const_iterator * x;
      …
    }
    

    This maybe illustrates the problem a little better as it’s more compact. As already said it’s not clear for the parser whether C::const_iterator is a type name or a static data member as it doesn’t know what C is when it parses this part of the code (it may know at a later point in time when the template is actually instantiated). So to ease the compiler implementers’ lives this ambiguity is resolved to “not a type name” and if the programmer wants to use a type name which is nested inside anything that is dependent on a template parameter he/she has to use the typename keyword in front of the name to let the compiler know that it should be treated as a type name.

    Unfortunately there is an exception to that rule regarding nested dependent type names when using them inside a base class list or the base class identifier in a member initialization list.

    template<typename T>
    struct Base {
      struct Nested {
        Nested(int) {}
      };
    };
    
    template<typename T>
    struct Derived : public Base<T>::Nested { // typename not allowed here
      Derived(int i)
        : Base<T>::Nested(i) // nor here
      {}
    };
    

    Btw: You should set your console client’s charset to UTF-8, so you get ‘*’ instead of â*â.

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

Sidebar

Ask A Question

Stats

  • Questions 423k
  • Answers 423k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have found this paper. It deals with various P2P… May 15, 2026 at 11:36 am
  • Editorial Team
    Editorial Team added an answer Sure, you need to import the binary first: Import-Module C:\path\to\assemblyName.dll… May 15, 2026 at 11:36 am
  • Editorial Team
    Editorial Team added an answer For me works something like: rx = re.compile(r'(foo: ")(.*?)(".*)') s_new… May 15, 2026 at 11:36 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.