Forward declaration of a template class c++ -


i saw similar examples, didn't understand them please don't mark duplicate straight away. think there's simple solution problem, , i'm learning c++.

i want use:

template<class t, std::size_t n> class arnas_array { //a copy of std:array functionality, basically, here. }; 

in class header, file, example:

class options_databaze {  public:      struct options_to_save{         arnas_array<char, 123> option_name;         //char option_name[103];         int * option_value_pointer;      };   }; 

and can't work. forward declaration won't work:

template<class t, std::size_t n> class arnas_array; 

i don't know problem, first time i'm stuck here, examples gold.

error c2079: 'options_databaze::options_to_save::option_name' uses undefined class 'arnas_array<char,123>' 

the question has nothing templates. in c++ class type t must complete, in particular, if non-static class data member of type t declared (see 3.2/5 (one definition rule) section of standard, or read more human-readable version here).

"must complete" means definition of class t should precede definition of corresponding data member. common way achieve this, pointed out cameron in comments, put definition in header file , include header everywhere it's needed - same way when include standard headers such <vector>, <map> , on.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -