Skip to content

Instantly share code, notes, and snippets.

@thiagomg
Last active November 12, 2015 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomg/00a5ecca0d29aa1997e1 to your computer and use it in GitHub Desktop.
Save thiagomg/00a5ecca0d29aa1997e1 to your computer and use it in GitHub Desktop.
Ciclic dependency problem
//File main.cpp --------------------------
#include "main.h"
#include "int_vector.h"
//We're not using accumulate because our
//int_vector example doesn't support.
int get_total(const int_vector &v) {
int total = 0;
for(int i=0; i < v.size(); i++) {
total += v[i];
}
return total;
}
//File main.h ----------------------------
int get_total(std::vector<int> &v);
//File int_vector.h ----------------------
struct int_vector {
//implementation details ...
int size() { return _size; }
int operator[](int pos) {
return _data[pos];
}
int *_data;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment