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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:26:12+00:00 2026-05-30T15:26:12+00:00

I have a code of doubly Linked list and there are few lines of

  • 0

I have a code of doubly Linked list and there are few lines of that code which idea is not clear . I request for experts comments on the lines which have comment in the following .Its long since I last time used C++ . There are just two line which i indicated are not understandable for me.

template <typename T>
class double_linked
{
    struct node
    {
        T data;
        node* prev;
        node* next;
        node(T t, node* p, node* n) : data(t), prev(p), next(n) {}
    };
    node* head;
    node* tail;
public:
    double_linked() : head( NULL ), tail ( NULL ) {}
    template<int N>
    double_linked( T (&arr) [N]) : head( NULL ), tail ( NULL ) 
    {
        for( int i(0); i != N; ++i)
            push_back(arr[i]);
    }

    bool empty() const { return ( !head || !tail ); } // this doing? 
    operator bool() const { return !empty(); } // this doing? i know operators need in C++ but dont know the use of it here 
    void push_back(T);
    void push_front(T);
    T pop_back();
    T pop_front();

    ~double_linked()
    {
        while(head)
        {
            node* temp(head);
            head=head->next;
            delete temp;
        }
    }
};
  • 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-30T15:26:13+00:00Added an answer on May 30, 2026 at 3:26 pm

    operator bool() const is a conversion operator. If an instance of double_linked is used in a context where a bool is required, this function will be called to do the conversion. (And will evaluate to true if the list is not empty in your case.)

    The other function is a plain old function, which will return true if either head or tail is null.

    For more about conversion operators, see: How do conversion operators work in C++?

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

Sidebar

Related Questions

I have tried to implement doubly linked list in C++. Here is the code,
I have a simple doubly linked list example that I'm working on, but for
I have code that generates a List<string[]> variable but can't quite figure out how
I have been working with a doubly linked list. Everything works OK with the
I'm writing a doubly-linked list using TDD approach. This collection type is not thread
I have an assignment that I am terribly lost on involving doubly linked lists
I wrote the following code when trying to make a doubly-linked list with an
Im creating my own doubly linked list program (I know there is a list
I have a doubly linked list in C and I'm confused as to how
I'm having a problem with a doubly linked list so I have two questions.

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.