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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:50:29+00:00 2026-05-26T04:50:29+00:00

In file main.cpp… #include pqueue.h struct nodeT; struct coordT { double x, y; };

  • 0

In file main.cpp…

#include "pqueue.h"

struct nodeT;

struct coordT {
    double x, y;
};

struct arcT {
    nodeT *start, *end;
    double weight;
};

int arcComp(arcT *arg0, arcT *arg1){
    if(arg0->weight == arg1->weight)
        return 0;
    else if(arg0->weight > arg1->weight)
        return 1;
    return -1;
}

struct nodeT {
    coordT* coordinates;
    PQueue<arcT *> outgoing_arcs(arcComp); // error on this line
};

In file pqueue.h …

#ifndef _pqueue_h
#define _pqueue_h

template <typename ElemType>
class PQueue 
{
private:
    typedef int (*CallbackFunc)(ElemType, ElemType);
    CallbackFunc CmpFunc;

public:
    PQueue(CallbackFunc Cmp);
    ~PQueue();  
};

#include "pqueue.cpp"
#endif

In file pqueue.cpp

#include "pqueue.h"

template <typename ElemType>
PQueue<ElemType>::PQueue(CallbackFunc Cmp = OperatorCmp)
{
    CmpFunc = Cmp;
}

template<typename ElemType>
PQueue<ElemType>::~PQueue()
{
}

error C2061: syntax error : identifier 'arcComp'

  • 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-26T04:50:30+00:00Added an answer on May 26, 2026 at 4:50 am

    The syntax is simply invalid, you cannot initialise members in-place; use a constructor.

    struct nodeT {
        coordT* coordinates;
        PQueue<arcT *> outgoing_arcs;
    
        nodeT() : ougoing_arcs(arcComp) { }
    };
    

    Apart from that you cannot (usually) define templates in cpp files, you must put the complete definition inside the header file. Granted, you are #includeing the cpp file rather than treating it as a separate compilation unit but that’s still bad, if only because it will trip up programmers’ expectations and automated build tools.

    As a final side-note, your code is violating every single C++ naming convention I have ever encountered.

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

Sidebar

Related Questions

I have this C++ file (let's call it main.cpp ): #include <string> #include main.y.c
I have the main .cpp file with this: #include stdafx.h #include Form1.h #include <iostream>
I have the following source code in main.cpp: #include <iostream> #include <iomanip> int main()
Say you've got the following simple main.cpp file: #include <cstdlib> #include <iostream> #include <fstream>
I have a code that looks like this: int main () { fstream file;
In code: //file main.cpp LINT a = 12; LINT b = 3; a =
g++ -std=gnu++0x main.cpp In file included from main.cpp:6:0: CustArray.h: In constructor 'CustArray::CustArray()': CustArray.h:26:32: error:
I currently have a program where my main code is in a file main.cpp.
I have the file main.cpp open in my editor. I want to see the
My code is stored in a main.cpp file which contains the void main() function,

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.