Я хотел бы объявить конкретный вектор boost ublas в качестве глобальной переменной. Проблема в том, что объявление вне функции всегда приводит к ошибке.
Вот конкретный пример:
Следующий код выдаст несколько ошибок: (error C2143: syntax error : missing ';' before '<<=' error C4430: missing type specifier - int assumed. error C2371: 'test' : redefinition; different basic types
)
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/assignment.hpp>
using namespace boost::numeric::ublas;
vector<int> test(3);
test <<= 1,2,3;
void main () {
std::cout << test << std::endl;
}
Однако перемещение объявления в основную программу работает
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/assignment.hpp>
using namespace boost::numeric::ublas;
vector<int> test(3);
void main () {
test <<= 1,2,3;
std::cout << test << std::endl;
}