我正在尝试使用boost::adjacency_matrix graph 作为成员来创建我自己的类,但我遇到了编译错误。无法编译的示例类:
namespace zto {
typedef boost::adjacency_matrix<boost::undirectedS> Graph;
class SampleClass
{
public:
Graph g;
SampleClass();
};
和编译错误:
./src/sample.cpp: In constructor ‘zto::SampleClass::SampleClass()’:
./src/sample.cpp:27:31: error: no matching function for call to
‘boost::adjacency_matrix<boost::undirectedS>::adjacency_matrix()’
./src/sample.cpp:27:31: note: candidates are:
/usr/include/boost/graph/adjacency_matrix.hpp:622:5: note: template<class EdgeIterator,
class EdgePropertyIterator> boost::adjacency_matrix::adjacency_matrix(EdgeIterator,
EdgeIterator, EdgePropertyIterator, boost::adjacency_matrix<Directed, VertexProperty,
EdgeProperty, GraphProperty, Allocator>::vertices_size_type, const GraphProperty&)
/usr/include/boost/graph/adjacency_matrix.hpp:604:5: note: template<class EdgeIterator>
boost::adjacency_matrix::adjacency_matrix(EdgeIterator, EdgeIterator,
boost::adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty,
Allocator>::vertices_size_type, const GraphProperty&)
/usr/include/boost/graph/adjacency_matrix.hpp:593:5: note:
boost::adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty,
Allocator>::adjacency_matrix(boost::adjacency_matrix<Directed, VertexProperty,
EdgeProperty, GraphProperty, Allocator>::vertices_size_type, const GraphProperty&)
[with Directed = boost::undirectedS, VertexProperty = boost::no_property, EdgeProperty
= boost::no_property, GraphProperty = boost::no_property, Allocator =
std::allocator<bool>, boost::adjacency_matrix<Directed, VertexProperty, EdgeProperty,
GraphProperty, Allocator>::vertices_size_type = unsigned int]
/usr/include/boost/graph/adjacency_matrix.hpp:593:5: note: candidate expects 2
arguments, 0 provided
/usr/include/boost/graph/adjacency_matrix.hpp:474:9: note:
boost::adjacency_matrix<boost::undirectedS>::adjacency_matrix(const
boost::adjacency_matrix<boost::undirectedS>&)
/usr/include/boost/graph/adjacency_matrix.hpp:474:9: note: candidate expects 1
argument, 0 provided
看起来那个编译器认为Graph是一个函数?!
谁能告诉我,如何将boost::adjacency_matrix声明为我班级的成员?