“vector” was not declared in this scope

You’ve got the declaration in the cpp file and the definition in the header, it should really be the other way round. After you’ve swapped the files round remove using namespace std; from functia.h as it’s not good practice to pull in namespaces in header files. You’ll need to change the declaration to void fun(std::vector<double> … Read more

How to create a vector of class objects in C++?

This is actually a function declaration. The function is called myStack and it returns a vector<Site>. What you actually want is: The type of neighbours at the moment will store copies of the objects, not references. If you really want to store references, I recommend using a std::reference_wrapper (rather than using pointers):

Python 3: Multiply a vector by a matrix without NumPy

The Numpythonic approach: (using numpy.dot in order to get the dot product of two matrices) The Pythonic approach: The length of your second for loop is len(v) and you attempt to indexing v based on that so you got index Error . As a more pythonic way you can use zip function to get the columns of a list then use starmap and mul within a list comprehension:

Multidimensional Vectors in C++

If you are able to use C++11, multidimensional arrays and vectors of vectors can be initialized in a similar manner. However, there are differences that must be understood to access the elements without running into undefined behavior. For a multidimensional array, memory for the elements of the array is required to be allocated contiguously. For … Read more

I get this error: “glibc detected”

Even if you’re not allocating memory directly, it happens under the hood in vector code and you most likely corrupted some portion of memory by writing where you are not supposed to. The most likely reasons I can think of are: Writing to an element that is out of bounds Using a pointer/reference to an element that … Read more

error C2106: ‘=’ : left operand must be l-value

This error is being thrown for the same reason you can’t do something like this: Your version of Vector::at should be returning a reference rather than a value.Lvalues are called Lvalues because they can appear on the left of an assignment. Rvalues cannot appear on the left side, which is why we call them rvalues. You can’t … Read more