function declaration with STL in header c++ -


i pretty new concept of splitting program header , etc. normally, goes ok, in case have whole bunch of errors if try next:

suppose have .cpp file:

#include <iostream> #include <string> #include <map> #include <algorithm> #include <vector> #include "header.h" using namespace std;  int main() {     //some code here }  map <char, char> create(vector <char> &one, vector <char> &two) {     //some code here }  vector <char> conc(string phrase) {     // code here }   vector <char> result(vector<char> three, map <char, char> code) {     // code here } 

in header.h have:

map <char, char> create(vector <char> &one, vector <char> &two); vector <char> conc(string phrase); vector <char> result(vector<char> three, map <char, char> code); 

which function declarations.. if put them in .cpp program works great, if in header.h - not. you, please tell missing here?

i reading concept of splitting on cprogramming.com, never had example stl. thank you!

you use using namespace std; in cpp file, not in header (and don't use in header), should use qualified type names:

#ifndef header_h #define header_h  #include <string> #include <map> #include <vector>  std::map <char, char> create(std::vector <char> &one, std::vector <char> &two); std::vector <char> conc(std::string phrase); std::vector <char> result(std::vector<char> three, std::map <char, char> code);  #endif // header_h 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -