Source is very primitive and uses Stanford's lib vector.h
#include <iostream>
#include "vector.h"
void countIntRange(Vector<int>& v, int a, int b);
int main(){
Vector <int> v;
v.add(28);
v.add(1);
v.add(17);
v.add(4);
v.add(41);
v.add(9);
v.add(59);
v.add(8);
v.add(31);
v.add(30);
v.add(25);
int min = 10;
int max = 30;
countIntRange(v, min, max);
return 0;
}
void countIntRange(Vector<int>& v, int a, int b){
int count = 0;
for (int i = 0; i < v.size(); i++){
if (v.get(i) > a && v.get(i) < b){
count++;
}
}
cout << count;
}
while compiling g++ throws such error:
highlander@linux-f62d:~/Documents/CS106b/libs> g++ ex31.cpp
/tmp/ccfH1i0N.o: In function `Vector<int>::get(int) const':
ex31.cpp:(.text._ZNK6VectorIiE3getEi[_ZNK6VectorIiE3getEi]+0x4b):
undefined reference to `error(std::string)'
/tmp/ccfH1i0N.o: In function `Vector<int>::insert(int, int)':
ex31.cpp:(.text._ZN6VectorIiE6insertEii[_ZN6VectorIiE6insertEii]+0x6c):
undefined reference to `error(std::string)'
collect2: error: ld returned 1 exit status
This is error message.... What it doesn't like?
Here goes whole vector.h code https://gist.github.com/HighlanderGe/9023734