gsl - C++ strange behaviour with function call by value -
i have object class interface matrix struct found in gnu scientific library typedef double real_t; typedef unsigned short index_t; class matrix { gsl_matrix* m; public: matrix(index_t rows, index_t columns, real_t val); } matrix::matrix(index_t rows, index_t columns, real_t val) { m=gsl_matrix_alloc(rows,columns); gsl_matrix_set_all(m, val); return; } index_t matrix::rows(void) { return m->size1; } index_t matrix::columns(void) { return m->size2; } the problem if use function taking matrix object value one: void test_function(const matrix m){}; and use in program one int main() { matrix m(4,4,1); cout << m.rows() << '\t' << m.columns() << endl; test_function(m); cout << m.rows() << '\t' << m.columns() << endl; } i surprisingly obtain number of rows of matrix object m modified function test_function garbage value, if put keyword const before a...