我將團隊視爲Team對象的數組,匹配的是Team對象內的Match對象的數組。 thisMatch
被宣佈爲:無法將指針的值更改爲等於另一個指針
Match* thisMatch = new Match();
這就是我想要做的事:
&(teams[i].matches[foundMatches]) = thisMatch;
// I also tried another method:
(tams[i].matches + foundMatches) = thisMatch;
其中foundMatches
是一個int。
但是,無論我做什麼,我不斷收到此編譯器錯誤:
error: lvalue required as left operand of assignment
&teams[i].matches[foundMatches] = thisMatch;
^
任何人有任何想法,以什麼可能會錯了嗎?如果需要,我可以提供更多信息,但我認爲大部分內容都不相關。
如何聲明'匹配'? – braindf 2014-09-04 00:53:29
'teams [i] .matches = new Match [num];' – chaiv 2014-09-04 00:55:20
在這種情況下'matches'是一個指向數組的指針,而不是指針數組。你想要哪一個? – 2014-09-04 00:57:19