xaero
xaero

Reputation: 99

Adding header files in header files

#ifndef LISTTEST_H
#define LISTTEST_H
#include <vector>
#include <string>

template <class T>
class ListTest {
    public:
        vector<T>* encrypt(vector<T> *list, int* key);
        void setkeyLength(int keyLength);
        int getKeyLength();
    private:
        int keyLength;
};


#endif  /* LISTTEST_H */

I have included vector and string header files in my own header file, but in "vector* encrypt(vector list, int key);" the compiler is giving error that vector is undefined what am I am doing wrong here

Upvotes: 1

Views: 123

Answers (2)

Donotalo
Donotalo

Reputation: 13025

They are contained in std namespace:

std::vector<T>* encrypt(std::vector<T> *list, int* key);

Upvotes: 1

Qaz
Qaz

Reputation: 61910

You need to qualify the vector using std::vector, as it's part of the std namespace. You should also consider removing <string>, as you don't use it in the header.

Upvotes: 2

Related Questions