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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:53:48+00:00 2026-06-09T21:53:48+00:00

I have the following class using boost filesystem, but encountered the problem when compiling.

  • 0

I have the following class using boost filesystem, but encountered the problem when compiling.

/// tfs.h file:

#include <boost/filesystem.hpp>
#include <iostream>
#include <string>

using namespace boost;
using namespace std;

class OSxFS
{
  public:
    OSxFS(string _folderPath)
    {
      mFolderPath(_folderPath);
    }

    string ShowStatus()
    {
      try
      {
        filesystem::file_status folderStatus = filesystem::status(mFolderPath);
        cout<<"Folder status: "<<filesystem::is_directory(folderStatus)<<endl;
      }
      catch(filesystem::filesystem_error &e)
      {
        cerr<<"Error! Message: "<<e.what()<<endl;
      }
    }

  private:
    filesystem::path mFolderPath;
}

In the m.cpp file, I use the following code to invoke the OSxFS class:

///m.cpp file 

#include "tfs.h"
#include <iostream>
#include <string>

using namespace std;
using namespace boost;

int main()
{  
  string p = "~/Desktop/";
  OSxFS folderX(p);
  folderX.ShowStatus();
  cout<<"Thank you!"<<endl;
  return 0;
}

However, I got the error message when I compile them by g++ in xCode:

In file included from m.cpp:1:
tfs.h: In constructor ‘OSxFS::OSxFS(std::string)’:
tfs.h:13: error: no match for call to ‘(boost::filesystem::path) (std::string&)’
m.cpp: At global scope:
m.cpp:5: error: expected unqualified-id before ‘using’

If I implement the function ShowStatus() of class OSxFS in a single main.cpp, it works. So, I guess the problem is about how to pass the string variable _folderPath to the class’s constructor?

  • 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-09T21:53:49+00:00Added an answer on June 9, 2026 at 9:53 pm

    You are missing a semicolon at the end of class OSxFS. Also, you are using the incorrect syntax to call the constructor of path. Try:

    OSxFS(string _folderPath) :
        mFolderPath(_folderPath)
    { 
    }
    

    mFolderPath(_folderPath); in the body of the OSxFS constructor is attempting to call mFolderPath as a function.

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

Sidebar

Related Questions

I have the following code: #include <iostream> #include boost/shared_ptr.hpp using boost::shared_ptr; class Base {
I have the following situation (simplified): a.h: #include <boost/serialisation/serialisation.hpp> class B; using namespace std;
I have the following class #ifndef Container_H #define Container_H #include <iostream> using namespace std;
I am trying to run the following program using boost::thread. #include <boost/thread.hpp> #include <iostream>
I have the following problem using template instantiation [*]. file foo.h class Foo {
I am learning boost::mpl and I have the following class - #include <string> #include
Using boost python I need create nested namespace. Assume I have following cpp class
I have defined the following class using COM to use the IGroupPolicyObject using C#.NET:
I am using Tornado and I have the following code: class UserHandler(RequestHandler): def get(self):
I am using appengine, webapp2 framework. I have the following model: class Match(db.Model): date_time

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.