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

  • Home
  • SEARCH
  • 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 8672063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:06:31+00:00 2026-06-12T19:06:31+00:00

Possible Duplicate: Why should the implementation and the declaration of a template class be

  • 0

Possible Duplicate:
Why should the implementation and the declaration of a template class be in the same header file?

was hoping you could help me out.

I know this question (after doing a google search) has been asked millions of times. I’m sure the solution to my problem is in one of those millions of asked questions, but I couldnt find it so I decided to ask.

I am getting this error specifically:

Error 1 error C2512: ‘NodeQueue’ : no appropriate default constructor available a:\work\fast\semi 5\automata\assignments\progass1\progass1\progass1\tree.h 33 1 progass1

the specific line has this defination:

level=new NodeQueue<Node>;

getting the same error for the next line as well but the cause is the same..

I’ve got default contructors for everything not sure why this is happening.. Here are parts of the code:

the top part of the header file:

#include <iostream>
using namespace std;

#include "intarr.h"
class Node;
template <typename t>
class QueueNode;

template <typename t>
class NodeQueue;

Tree:

class Tree{

    Node* root;


    int level_length;
    Node* curr;
    NodeQueue <Node>* level,*level_bak;
public:

    Tree(){
        root=NULL;
        level_length=0;
        curr=NULL;
        level=new NodeQueue<Node>;
        level_bak=new NodeQueue<Node>;
    }
// I doubt you need the rest...

class node

class Node{
public:
    Node *top,*right,*bottom,*left,*prev;
    Node *a,*b,*c;
    int row,col;
    Node(){

    }
    Node(int x,int y){
        top=right=bottom=left=prev=NULL;
        row=x;col=y;
        a=b=c=NULL;
    }

};

queuenode (i.e queue’s node)

 template <typename t>
     class QueueNode {
     public:
        QueueNode* next;
        QueueNode* prev;

        t *value;
        QueueNode(){

        }
        QueueNode(t* value){
            next=NULL;
            this->value=value;
        }

    };

nodequeue:

 template <typename t>
 class NodeQueue {
    QueueNode *head;
    QueueNode *tail;

    //lhs=bottom;

 public:
     NodeQueue(){
        head=NULL;
        tail=NULL;
    }
//....... rest of the code you dont need
  • 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-12T19:06:32+00:00Added an answer on June 12, 2026 at 7:06 pm

    Since this is a compiler error (not linker, as most template error questions), I’m guessing it’s because you forward-declare the type:

    template <typename t>
    class NodeQueue;
    

    why do you forward-declare it instead of including the file? To construct an object you need the full definition, so #include "NodeQueue.h".

    Use forward declarations where a complete type isn’t needed.

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

Sidebar

Related Questions

Possible Duplicate: Why should the implementation and the declaration of a template class be
Possible Duplicate: Why should the implementation and the declaration of a template class be
Possible Duplicate: Why should the implementation and the declaration of a template class be
Possible Duplicate: Why can templates only be implemented in the header file? Why should
Possible Duplicate: Why can templates only be implemented in the header file? Why should
Possible Duplicate: Why can templates only be implemented in the header file? Why should
Possible Duplicate: Should C++ eliminate header files? In languages like C# and Java there
Possible Duplicate: Why should the interface for a Java class be prefered? When should
Possible Duplicate: Should we support IE6 anymore? ripie6.com I would like to know which
Possible Duplicate: How should I include a js file from another js file? In

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.