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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:24:39+00:00 2026-05-21T18:24:39+00:00

i have recently come to this error , i search a lot but i

  • 0

i have recently come to this error , i search a lot but i could not find the solution , i made a win 32 console application(c++) in visual studio 2010 and added 2 header files and 1 .cpp file with main function in it , i did not change the project’s properties , your help would be really appreciated.
here is my code:

//listNode.h:
#ifndef LISTNODE_H

#define LISTNODE_H

template< typename item > class Node
{

private:

    item data;
    Node<item> *next;

public:

    Node( item d , Node<item> *n );
    void setData( item d );
    item getData();
    void setNext( Node *n );
    Node<item>* getNext();

};

template< typename item > 
    Node< item > :: Node( item d , Node *n )
    {
        data = d;
        next = n;
    }

    template< typename item>
    void Node< item > :: setData( item d )
    {
        data = d;
    }

    template< typename item>
    item Node< item > :: getData()
    {
        return data;
    }

    template< typename item >
    void Node< item > :: setNext( Node *n )
    {
        next = n;
    }

    template< typename item >
    Node<item>* Node<item> :: getNext()
    {
        return next;
    }

#endif  


//list:
#ifndef LIST_H
#define LIST_H

#include "listNode.h"

template < typename item > class List
{
private:

    Node<item> *first;
    Node<item> *last;
    int numberOfElements;

public:

    List( Node<item> *f , Node<item> *l , int num );
    ~List();
    void addFront( item d );
    void addRear( item d );
    void removeFront();
    void removeRear();
    item front();
    item rear();
    bool isEmpty();
    int size();
    void print();

};


template < typename item >
List<item> :: List( Node<item> *f , Node<item> *l , int num )
{
    first = f;
    last = l;
    numberOfElements = num;
}

template < typename item >
List<item> :: ~List()
{
    for( int i=0 ; i<nummerOfElements ; i++ )
    {
        Node<item> temp = *first;

        delete *first;

        first = temp.getNext();

    }

    first = 0;
    last = 0;
    numberOfElements = 0;
}



template < typename item >
void List<item> :: addFront( item d )
{
    Node<item> newNode( d , first );

    first = &newNode;

    numberOfElements++;
}

template < typename item >
void List<item> :: addRear( item d )
{
    Node<item> newNode;
    newNode.setData(d);

    if( numberOfElements != 0 )
        *last.setNext( &newNode );

    last = &newNode;

    numberOfElements++;
}


template < typename item >
void List<item> :: removeFront()
{
    if( numberOfElements != )
    {

        Node<item> temp = *first;

        delete *first;

        first = temp.getNext();

        delete temp;

        numberOfElements--;
    }

    else
        cout << "list is already empty!\n"
}

template < typename item >
void List<item> :: removeRear()
{
    if( numnerOfElements != 0 )
    {

        //finding the node before last : 

        Node<item> *beforeLast;

        beforeLast = first;

        while( true ) 
      {
          if( *beforeLast.getNext() == last )
              break;

          beforeLast = *beforeLast.getNext();
      }


        Node<item> temp = *last;

        delete *last;

        last = beforeLast;

        delete temp;

        numberOfElements--;
    }

    else
        cout<< "list is already empty!\n"
}

template < typename item >
item List<item> :: front()
{
    if( numberOfElements != 0 )
        return *first.getData();
    else
        return
        -1;
}

template < typename item >
item List<item> :: rear()
{
    if( numberOfElements != 0 )
        return *last.getData();
    else
        return -1;
}

template < typename item >
bool List<item> :: isEmpty()
{
    if( numberOfElements == 0 )
        true;
    else
        false;
}

template < typename item >
int List<item> :: size()
{
    return numberOfElements;
}



#endif


//main.cpp:

#include <string>
#include<iostream>

using namespace std;

#include "list.h"

template < typename item >
int main()
{
    string atom1("1");
    string atom2("2");
    string atom3("3");
    string atom4("5");
    string atom5("6");

    List<item> l1();

    l1.addRear( atom4 );
    l1.addRear( atom5 );

    List<item> l2();

    l2.addRear( atom1 );
    l2.addRear( atom2 );
    l2.addRear( atom3 );
    l2.addRear( l1 );

    cout << l2.front()


        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-05-21T18:24:40+00:00Added an answer on May 21, 2026 at 6:24 pm

    main is a special function in C++ – it cannot be a template. And if it could be, how would you provide the type(s) it is templated on? I think maybe you don’t quite understand templates yet.

    I have just checked this by creating a VC++ console project with a main that looks like this:

    template <typename T>
    int main() {}
    

    and I get exactly the link error message you get, but no compilation error (which there should be).

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

Sidebar

Related Questions

I have never come across this issue but most recently I noticed that a
My co-worker and I have come across this warning message a couple times recently.
I have recently started learning c# and have come across an issue. I'm not
Recently i have come across this statement : InputStream in = new FileInputStream(Filename); What
This error has come up recently in my eclipse android maven project, and I
I've recently come across this error within a custom cms i'm building - this
I have recently come upon an error when I added the following to my
I have recently come across an interesting question on strings. Suppose you are given
I have recently been working on a Pastebin script (for fun) and I've come
A few questions have come up recently involving the Application.Evaluate method callable from Excel

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.