Create a gist now

Instantly share code, notes, and snippets.

@thiagomg /main.cpp
Last active Nov 12, 2015

What would you like to do?
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