For example I wanted to have a variable of type auto because I\'m not sure what type it will be.
When I try to declare it in class/struct declaration it
Indirectly, provided that you don't reference a member of the class.
This can also now be achieved through deduction guides, these were introduced in C++17 and have recently (finally) support in VC++ has been added (clang and GCC already had it).
https://en.cppreference.com/w/cpp/language/class_template_argument_deduction
For example:
template
struct CString;
template
struct CString>
{
std::array const Label;
CString(std::array const & pInput) : Label(pInput) {}
};
template
CString(std::array const & pInput) -> CString>;
https://godbolt.org/z/LyL7UW
This can be used to deduce class member types in a similar manner to auto. Although the member variables need to be Dependant somehow on the constructor arguments.