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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:22:40+00:00 2026-05-25T23:22:40+00:00

and I am trying to now do a Breadth First Order for files but,

  • 0

and I am trying to now do a Breadth First Order for files but, when I implement this template class to use a Queue I get this errors?, any idea where this might be?, also I do not understand the way the line number where the error is, is specified (i.e myprogram.c:23:10) no idea where that is

program.c:11:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
program.c:22:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
program.c:33:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
program.c: In function ‘display_info’:
program.c:49:3: error: ‘q_type’ undeclared (first use in this function)
program.c:49:3: note: each undeclared identifier is reported only once for each function it appears in
program.c:49:10: error: ‘string’ undeclared (first use in this function)
program.c:49:18: error: ‘bfFilesQueue’ undeclared (first use in this function)
program.c:50:18: error: ‘bfDirsQueue’ undeclared (first use in this function)

Now the Queue class was taken from here, and I want to use it with strings , basically a file path

http://www.java2s.com/Code/Cpp/Generic/Createagenericqueue.htm

So my questions are, because i don’t expect you to debug this for me.. but want to know the following:

  • I tried to declare the queue at the top after the #include’s so that i have have access to them globally. It seems like it does not like it because i am trying to use it from the display_info function. How can I declare this so that I have access to those Queues from anywhere?

  • I dont understand how to check in which line it is telling about the error (i.e. :12:10), i took that Template class from the link i posted.. not sure why would it throw an error.. How can I know the line number based on those weird numbers?

So the code and errors are just informational so that you may answer those two questions with enough information.. any help will be much appreciated.

Thank you

#define _XOPEN_SOURCE 500
#include <ftw.h>
#include <stdio.h>
#define SIZE 100

template <class Qtype> class q_type {
    Qtype queue[SIZE]; 
    int head, tail;    
public:
    q_type() { 
        head = tail = 0; 
    }
    void q(Qtype num); 
    Qtype deq();  
};  

template <class Qtype> void q_type<Qtype>::q(Qtype num)
{
    if(tail+1==head || (tail+1==SIZE && !head)) {
        cout << "Queue is full.\n";
        return;
    }
    tail++;
    if(tail==SIZE) 
        tail = 0; // cycle around
    queue[tail] = num;
}

template <class Qtype> Qtype q_type<Qtype>::deq()
{
    if(head == tail) {
        cout << "Queue is empty.\n";
        return 0;  
    }
    head++;
    if(head==SIZE) 
        head = 0; 
    return queue[head];
}

q_type<string> bfFilesQueue;
q_type<string> bfDirsQueue;


static int display_info(const char *fpath, const struct stat *sb,
        int tflag, struct FTW *ftwbuf)
{

    //Check the type of Flag (i.e File or Directory)
    switch(tflag)
    {
        case FTW_D: 
        case FTW_F: 
            bfFilesQueue.q(fpath);
            break;

        case FTW_DP: 
            bfDirsQueue.q(fpath);
            break;
    }
    return 0; /* Continue */
}
  • 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-25T23:22:41+00:00Added an answer on May 25, 2026 at 11:22 pm

    program.c:11:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘<’ token

    That sounds like you’re compiling the C++ source code as C.

    A simple fix can then be to rename the file as program.cpp.

    Cheers & hth.,

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

Sidebar

Related Questions

I am now trying to use Preference class using Preferences pfrOfThis = Preferences.userNodeForPackage(this) It
I am trying to implement a breadth first traversal for a maze. This is
I'm trying to make an iterator that performs breadth-first traversal of all the files
I've done the breadth-first search in a normal way. now I'm trying to do
I'm now trying to create a xml-rpc server with the CodeIgniter Framework. <?php $this->load->library('xmlrpc');
I am now trying to implement a simple HTML webpage scraper using Java.Now I
I'm now trying to parse chrome bookmarks, but I encounter a problem. the bookmarks
I am a C++ user and now trying to use c#. In c++ taking
I asked this question earlier and am now trying to explore the idea of
I've been struggling for a while now trying to figure this out and I'm

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.