Как я могу написать функцию, которая принимает Std :: массив разного размера? Я использую std :: array , потому что его можно использовать с contexpr
Например,
Код: Выделить всё
using columWidth = int;
class student{
constexpr std::array mHeader=
{
{"Name", 150}, //name column has width 150
{"id", 100} // id column has width 100
}; //total 2 columns . so array size is 2.
std::vector data;
};
class teacher{
constexpr std::array mHeader=
{
{"Name", 150},
{"Degree", 100},
{"University", 100},
};
std::vector data;
};
class Table
{
public:
void setHeader(); //this should accept std::array of different size, how ?
void createTable();
void changeTableIndex(int index);
private:
mHeader ; // what should be the type of this header ? and how to receive and store this header ?
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... erent-size