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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:58:38+00:00 2026-06-05T10:58:38+00:00

Here I’m making a circular linked list ( template <class t> class clist; )

  • 0

Here I’m making a circular linked list ( template <class t> class clist; ) with a member function, concat () used to concatenate one list at the end of the other. The problem lies in this function. Now when I’m concatenating two clist with same template parameters (let say both be clist<int>) then function works fine, but as soon as I try concatenate two clists ( clist <int> c1 and clist <char> c2) then I need to do some casting in the function concat, and as I dont know much about templates, I cudnt actually figure out how to do that.

So the problem precisely is with the last second line of the program below. I have clist <int> c1 whose member function concat is being called, and clist <char> c2 which is being concatenated at the end of c1.

template <class t>
class clist
{
    struct node
    {
    t data;
    node* next;
    node (const t& x=0, node* nxt=0): data(x), next(nxt) { }
    };

    typedef node* NPTR;

    public:

    NPTR ptr;

    template <class r>
    void concat ( clist <r> & );

    // other functions like push, pop etc. to form the clist

    clist () : ptr(0) { }
};

template <class t>
template <class r>
void clist<t> :: concat ( clist <r>& c2 )
{
    // ptr is pointer to a certain node in the list through which the list is
    // accessedand is zero initially.

    if ( c2.ptr == 0 ) return;
    if ( ptr == 0 ) ptr = (NPTR) c2.ptr;
    else
    {
    NPTR p = ptr->next;
    ptr->next = (NPTR) c2.ptr->next;
    c2.ptr->next = ( ??? ) p ;
    ptr = (NPTR)c2.ptr;
}

Whatever I try it still shows the error cannot convert 'clist<int>::node*' to 'clist<char>::node*' in assignment.

Can somebody please tell what is the proper way of casting here ?

  • 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-05T10:58:40+00:00Added an answer on June 5, 2026 at 10:58 am

    The cast is actually saving you from making a heterogeneous list. What you seem to be trying to do is to concatenate two lists – one with int and one with char. Now conceptually that might seem reasonable but the structure of an int node and a char node are too different.

    The only way this could make sense is if you copied the second list into a clist of ints and then concatenated.

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

Sidebar

Related Questions

Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
Here's my scenario: <!-- Normal Control --> <div class=required> <label for=address1>Address line 1</label> <input
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
Here an example of my checkbox list http://jsfiddle.net/YnM2f/ Let's say I check on G
Here is my code: echo '<table class=class1><tbody>'; while ($row1=mysql_fetch_array($result1)){ echo '<tr><td>'.$row1['firstname'].'</td><td>'.$row1['lastname'].'</td></tr>'; } echo '</tbody></table>';
Here is an example of what I need http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html I need interactive list to
Here's my situation: I have a Data Template set up which contains a ToggleButton
Here's some CSS and HTML to make a textarea below a list of data

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.