Home > Back-end >  C should be how to use class to invoke the vector without calling pointer?
C should be how to use class to invoke the vector without calling pointer?

Time:09-21

Everyone a great god is good, I want to achieve a function calls to the vector container, rather than a pointer, the main function, called the vector, CPP, call the function is a sum function, a function called atsum. CPP, function header files for atsum. H,
The following is the main program
 
#include
#include
# include "ATSUM. H"
using namespace std;

Int main ()
{
Const int N=100;
Vector A (N);
Double s=0;
ATSUM Sum;
Sum. Atsum (a, s);
Coutreturn 0;
}

ATSUM. H header file content is
 
# # ifndef CLASSSUM_H
# define CLASSSUM_H
#include

The class ATSUM
{
Public:
Void atsum (STD: : vector & A, double s);
};

# endif

Function atsum. CPP for
 
#include
#include
# include "ATSUM. H"

using namespace std;

Void ATSUM: : ATSUM (vector & A, double s)
{
for(int i=0; i!=a.s considering (); I++)
S=s + a, [I].
}


Compile after error for
 
/TMP/ccC8QCeF. O: : in the function 'main'
Vector. CPP: (. Text + 0 xe7) :
'ATSUM: : ATSUM (STD: : vector & , double)
'Undefined reference

The STD: : vector In the source program for STD: : vector & Right, this come from? And how to make the call? Please god,

CodePudding user response:

Procedures should be no problem,
The compiler code of what there is a problem,
  • Related