C++ (Qt)struct TableDescriptor { QString tableName; QString header[]; int hiddenColumn[];};
C++ (Qt)TableDescriptor tableMachines = {"machines", {"Id","Machine Name","Power","Speed", QString::null}, {0}};
C++ (Qt)typedef QList<int> IntList;struct TableDescriptor { TableDescriptor( const QString &tn, const QStringList &hdr, const IntList &hc ) : tableName( tn ), header( hdr ), hiddenColumn( hc ) { } QString tableName; QStringList header; IntList hiddenColumn;}; ... TableDescriptor tableMachines( "machines", QStringList() << "Id" << "Machine Name" << "Power" << "Speed", IntList() << 1 << 2 );
struct TableDescriptor { QString tableName; char header[1];};TableDescriptor* f(const QString &tableName, const char header[]) { TableDescriptor* ret = static_cast<TableDescriptor*>( ::operator new char(sizeof(TableDescriptor) + strlen(header))); ret->tableName = tableName strcpy(ret->header, header); return ret;}
::operator new char[ sizeof(TableDescriptor) + strlen(header) ]
C++ (Qt)TableDescriptor* f(const QString &tableName, const char header[]) { TableDescriptor* ret = new ( ::operator new (sizeof(TableDescriptor) + strlen(header)) //new char[sizeof(TableDescriptor) + strlen(header)] //можно и так :) ) TableDescriptor; ret->tableName = tableName strcpy(ret->header, header); return ret;}