Array type xxx is not assignable
問題
在 world_type.h裡面的struct。species_t也是一個struct。
struct world_t
{
unsigned int numSpecies;
species_t species[MAXSPECIES];
unsigned int numCreatures;
creature_t creatures[MAXCREATURES];
grid_t grid;
};
試圖 initialize 一個 world_t world 的 species 陣列,但是報錯 ”Array type ‘species_t [10]’ is not assignable“
world = {(unsigned)numSpecies};
world.species = species;
原因
上面的程式碼中,我嘗試將species陣列賦值給world的species。但是在C++中,不能利用等式給陣列賦值。只能逐個給陣列的element賦值。
解決方案
world = {(unsigned)numSpecies};
for(int i = 0; i < numSpecies; i++){
world.species[i] = species[i];
}
相關文章
- type[xxx]的用法
- error: ‘xxx’ does not name a typeError
- xxx cannot be resolved to a type
- test oracle array的使用,透過type來自定義arrayOracle
- PostgreSQL cache lookup failed for type XXXX 錯誤SQLAI
- QT中error: xxx does not name a type xxx錯誤QTError
- vue Cannot find module @/xxx/xxx.ts or its corresponding typeVue
- a commponent required a bean of type XXXXXX that could not be found-2022新專案UIBean
- eclipse :報錯 ‘XXXX‘ does not name a type的解決辦法Eclipse
- The type XXX cannot be resolved.It is indirectly referenced from required .classUI
- Qt5.7中報錯“xxx dose not name a type”的原因;QT
- 更新xcode8後真機除錯報code signing is required for product type 'xxxxx' in SDK 'iOS 10.0'XCode除錯UIiOS
- Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa(解決的兩種方式)Go
- Error querying database. XXXXXXXXXXXXX, No database selected。ErrorDatabase
- Error building Player: Win32Exception: ApplicationName=‘xxxxxxxxxxxxxxxxxx//sdk\tools\zipalign.exe' ...ErrorUIWin32ExceptionAPP
- Internal Error with background job scheduling XXXXXXXXXXXXX.Error
- 編譯錯誤導致浪費10多分鐘, 編譯錯誤的提示:xxx does not name a type xxx編譯
- // @require file://C:xxxxxxxxx.jsUIJS
- mysql Incorrect key file for table ‘/xxxxxxxx/xxxx.MYI'; try to repair itMySqlAI
- 解決Tensorflow ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)ErrorAIObject
- undefine macro xxxxxMac
- array new 與 array deletedelete
- Spring:錯誤No bean named 'xxxxxxx' availableSpringBeanAI
- PHP array_flip() array_merge() array+array的使用總結PHP
- (徵文模板參考)xx技能樹/職業路線評測-xxxxxxxx
- array
- variable: Type 與 Type variable
- Linux下編譯國標GB28181視訊推流元件EasyGBD報錯undefined reference to `xxxxxxxx@GLIBC_xxxxx‘解決Linux編譯元件Undefined
- Maven專案報錯:No bean named 'xxxxxx' availableMavenBeanAI
- [Linux] mutt /xxxx/xxxx/sent is not a mailbox.LinuxAI
- webstorm vue3+ts報錯:Cannot find module ‘@/views/xxx.vue‘ or its corresponding type declarationsWebORMVueView
- Array()與Array.of()方法區別
- cannot convert (type interface {}) to type int: need type assertion
- JS Array.reduce 實現 Array.map 和 Array.filterJSFilter
- PHP用foreach來表達array_walk/array_filter/array_map/array_reducePHPFilter
- C++ vector<std::tuple<XXX, XXX, XXX>>C++
- array_filter ()、array_map ()、array_walk () 區別?容易記混淆!!!Filter
- Value Type vs Reference Type in SwiftSwift