title: call function without object in c++
body: <p>I am new to c++ and have a trouble with functions that does not seems to be a bit unusual (or maybe I just do not know the right name). I have created a class vector that is supposed to work like the c++ vector, but is probably a bit simpler. I know that whenever possible you should use the already existent classes, but for the practice I want to create an own vector class.</p>
  
  <p>So what I want to do is simply to create a function that can be called somehow "stand alone". Earlier I have managed to create a function scalar (calculates scalar product) that can be called like,</p>
  
  <pre><code>myVector v1(5);
  myVector v2(5);
  
  for(int i=0; i&lt;5; i++){ //missing proper function here, this is not part of the question
      v1[i] = i;
      v2[i] = i+1;
  }
  double prod = v1.scalar(v1,v2);
  //or better
  double prod2 = v1.scalar(v2);
  </code></pre>
  
  <p>However what I really want to do is to create a function that does not need to operate on an object to work. I want to use the function something like</p>
  
  <pre><code>double prod3 = scalar(v1,v2);
  </code></pre>
  
  <p>is this possible and where should I define the function. I do want it to have the properties of an ordinary function rather than a inline function if possible. Also if this kind of functions have a name I would be happy to know.</p>
  
  <p>/BR Patrik</p>