I find it difficult to get the exact meaning of these terms in C++. It seems like there is a lot of overlap between one another (at least typedef and namespace). Can you please enlighten me why were these concepts invented in C++; and in what scenarios should we use each one of these ?
Also this discussion is particularly confusing. It says 'typedef' and 'using' are the same. It makes me wonder, why do we have two different terms if they are almost the same ?
Due to poor understanding of these terms I coded the following and got the error shown below:
Files.hpp
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <fstream>
#include <ostream>
#include <iomanip>
#include <cmath>
class Files {
public:
//@Brief: We create some short forms for long type names
typedef boost::filesystem FS; //! Short form for boost filesystem
// Short form for file name pairs (for example, <200.jpg, 200>)
typedef std::pair<FS::path, int> file_entry;
// Short form for vector of tuples
typedef std::vector<file_entry> vec;
// Short form for iterator of type, boost::filesystem::directory_iterator
typedef FS::directory_iterator dirIter;
};
The following is the make error that I receive:
...../include/Files.hpp:10:20: error: ‘filesystem’ in namespace ‘boost’ does not name a type
typedef boost::filesystem FS; //! Short form for boost filesystem