我正在嘗試使用boost :: adjacency_matrix圖形作爲成員來嵌套自己的類,但是我在編譯時出錯。 Sample類不會編譯:我是否可以用自己的類來包裝增強圖形
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
它看起來像compilator認爲圖是一個功能?
有人可以告訴我,如何聲明boost :: adjacency_matrix作爲我的班級的成員?
thx很多,這解決了我的問題。 – miszczu