function)
somthing like this:
int hello(int argc,char **argv){
return argc;
}
hello ("hi","hello",hey"); //output 3
hello ("hi"); //output 1
C or C++?
There are several options, I start with those i prefer: Template Parameter Pack: template <class... Args> void count_1(Args const ... list) { std::clog << sizeof...(list) << std::endl; } Template Value Parameter: template <class T, std::size_t N> void count_2(T(&list)[N]) { std::clog << N << std::endl; } STL Container: template <class T> void count_3(std::vector<T> const& list) { std::clog << list.size() << std::endl; } template <class T> void count_4(std::initializer_list<T> const& list) { std::cout << list.size() << std::endl; } http://cpp.sh/9clyu
You'r welcome.
Обсуждают сегодня