今天我和我的朋友讨论了在C ++中传递对象数组的正确方法。这两者之间是否存在效率差异:
class myform(FlaskForm):
connection = removed
result = connection.execute("SELECT * FROM sqltable")
result = result.fetchall()
scenarioList = []
fieldList = []
fieldLabel = []
for scen in result:
scenarioList.append("Scenario: " + scen[0])
fieldList.append("field: " + scen[0])
for i in range(len(result)):
fieldLabel.append("My Field" + str(i + 1))
myDynamicFields = dict(zip(fieldLabel, fieldList))
formID = StringField('Form ID')
for key, val in myDynamicFields.items():
exec(key + '=StringField(val)')
Struct Apple {
std::string color;
}
void colors(Apple A[]) {
A[0].color = "red";
}
int main() {
Appple apples[10];
colors(apples);
return 0;
}