dimanche 23 août 2015

error: invalid operands of types ‘clock_t {aka long int}’ and ‘

i'm trying to measure the elapsed time in C++ , so i have used the following function

#include <ctime>
void f() {
  using namespace std;
  clock_t begin = clock();

  code_to_time();

  clock_t end = clock();
  double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
}

after compiling (i'm using c++11) i get the following error :

error: invalid operands of types ‘clock_t {aka long int}’ and ‘<unresolved overloaded function type>’ to binary ‘operator-’
            double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;

Any help will be appreciated :) , thanks.

Aucun commentaire:

Enregistrer un commentaire