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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:41:51+00:00 2026-06-16T06:41:51+00:00

I am facing issue in declaration of inner template class. I have create a

  • 0

I am facing issue in declaration of inner template class.

I have create a Class A in a.h here is my code looks like

class A
{
  public:

  private:
    // How declare LockFreeQueue here

};

template <typename T>
struct LockFreeQueue
{
      LockFreeQueue();
      void push(const T& t);
      bool pop(T& t);
    private:
      typedef std::list<T> TList;
      TList list;
      typename TList::iterator iHead, iTail;

};

/**
 * Constructor
 * Initializes required variables
 * */
template <typename T>
LockFreeQueue<T>::LockFreeQueue()
{
  list.push_back(T());
  iHead = list.begin();
  iTail = list.end();
}

/**
 * pushes data in the list
 * @param datatype that needs to be pushed
 * */
template <typename T>
void LockFreeQueue<T>::push(const T& t)
 {
   list.push_back(t);
   iTail = list.end();
   list.erase(list.begin(), iHead);
 }

/**
 * Pops Queue
 * @param t stores popped data at t's address
 * @return true if data available, false otherwise
 * */
template <typename T>
bool LockFreeQueue<T>::pop(T& t)
{
  typename TList::iterator iNext = iHead;
  ++iNext;
  if (iNext != iTail)
  {
    iHead = iNext;
    t = *iHead;
    return true;
  }
  return false;
}

Any help would be highly appreciated,

Thanks & BR
Yuvi

  • 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-16T06:41:52+00:00Added an answer on June 16, 2026 at 6:41 am

    Just move it inside:

    class A
    {
      public:
    
      private:
    
          template <typename T>
          struct LockFreeQueue
          {
              LockFreeQueue();
              void push(const T& t);
              bool pop(T& t);
             private:
              typedef std::list<T> TList;
              TList list;
              typename TList::iterator iHead, iTail;
          };
    };
    

    And add the scope of A when defining, like this:

    template <typename T>
    A::LockFreeQueue<T>::LockFreeQueue()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im facing an issue with The following: public class Person { private long id;
I'm facing a issue with opening mail client using openURL. Here is the code.
I am facing issue with run simple Hbase example. I have create on HbaseTest.java
I have been facing issue with sphinx result set for string attribute. Below is
We have implemented webservice which generates xml response. I am facing issue while invoking
issue facing while loading the messages in to mq channel, recieving an error like
I'm facing an issue using eval function. Indeed I have some function name inside
I'm facing issue with redirecting the viewControllers using pop/pushViewControllers. I've three view controller like
I am a newbie to Qt and facing issue in my application. So here
I am facing issue while trying into insert special symbols like pound character (£

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.