0

This is the code I have written for average.h

#ifndef _average_h
#define _average_h
#include<vector>
double avg(std::vector<double> a);
#endif

This is the code I have written for average.cpp

#include "average.h"
using namespace std;

double avg(std::vector<double> a)
{
    double sum=0;
    for(int i=0;i<a.size();i++)
    {
        sum=sum+a[i];   
    }
    return sum;
}

This is the code I have written for main.cpp

#include "average.h"
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    vector<double> b;
    double x;
    while(cin)
    {
        b.push_back(x);
    }
    double res=avg(b);
    cout<<res;
    return 0;
}

I can't understand what's the problem. Please help.

dlmeetei
  • 9,905
  • 3
  • 31
  • 38
  • 3
    That's an error with your linker. What was it more specifically? Did you include `libstdc++` when linking? – tadman Jul 19 '17 at 03:39
  • 1
    I'm not familiar with dev-c++, but if it gives you access to the command lines executed to build the program, I recommend adding them along with the full text of the error messages. – user4581301 Jul 19 '17 at 03:57
  • You need to find where Dev-C++ prints the entire error message. – Code-Apprentice Jul 19 '17 at 05:09
  • You really should learn to compile on the command line (e.g. using `g++` program with [GCC](http://gcc.gnu.org/)....); using an IDE like DevC++ just hides the *important* compilation steps. The compiler is probably [GCC](http://gcc.gnu.org/) and certainly a command-line program. – Basile Starynkevitch Jul 19 '17 at 05:09
  • 1
    You probably didn't add both .cpp files to the project – M.M Jul 19 '17 at 05:10

0 Answers0