Oke,
I think that the meaning of this exercise is a practise of using header files.
I solved most of the errors , but I still have one.
code main.cpp
Code:
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
#include "square.h"
using namespace std;
int main()
{
vector<int> nummer;
int teller ;
// filling the vector with the numbers 1 till 100
for (teller=0; teller < 100; teller++ )
{
nummer.push_back(teller);
}
// compute and write the square
for (teller=0 ; teller < 100 ; teller++)
{
double uitkomst = wortel (nummer[teller]); // function where the square is computed.
streamsize prec = cout.precision();
cout << setprecision(3) << uitkomst
<< setprecision(prec);
}
cout << endl;
return 0;
}
code square.h
Code:
#ifndef GUARD_square_h
#define GUARD_square_h
// `grade.h'
#include <vector>
int wortel(int);
#endif
and as last square.cpp
Code:
#include <vector>
#include "square.h"
// compute a student's overall grade from midterm and final exam grades and homework grade
int wortel (int nummer)
{
return sqrt(nummer);
}
The only error I get now is :
C:\Users\wobben\Desktop\borland-source\chapter04\wortel\main.o:main.cpp|| undefined reference to `wortel(int)'|
What wrong here ?
Roelof