Last active
November 12, 2015 00:10
-
-
Save thiagomg/00a5ecca0d29aa1997e1 to your computer and use it in GitHub Desktop.
Ciclic dependency problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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