Home > Back-end >  New questions about the include header files
New questions about the include header files

Time:09-24

My header file Vec. H a class declaration in the Vec, class declares the three functions:
//returns the size of the current container
Size_type size () const;
//index operator function
T& Operator [] (size_type);
Const T& Operator [] (size_type) const;
In the Vec CPP defined in this three functions:
Template
Typename Vec : : size_type Vec : : size () const {
Return limit - the data;
}
Template
T& Vec : : operator (size_type I) [] {
The return data [I];
}
Template
Const T& Vec : : operator [] (size_type I) const {
Return * (data + I);
}
Then in Str. CPP in include the header file and call the three functions, is a function is undefined mistake, then I directly in the Vec. H header file statement class
Directly defines these three functions, compiled through, can to a great god said what reason is this

CodePudding user response:

At the end of the template to write a file
  • Related