gpt4 book ai didi

c++ - '*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul))) 中的 ‘operator=’ 不匹配

转载 作者:太空宇宙 更新时间:2023-11-04 06:01:10 25 4
gpt4 key购买 nike

我不断收到以下错误:

main.cpp: In function ‘int main()’:
main.cpp:41: error: no match for ‘operator=’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul))) = (Cache*)operator new [](((size_t)(((long unsigned int)ASSOC) * 32u)))’
cache.h:2: note: candidates are: Cache& Cache::operator=(const Cache&)
main.cpp:47: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’
main.cpp:50: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’
main.cpp:52: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’
main.cpp:53: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’
main.cpp:54: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’
main.cpp:55: error: no match for ‘operator[]’ in ‘*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul)))[j]’

代码如下:

int main() {
int ASSOC, BLOCKSIZE, NO_SETS, SIZE, i, k, l, j;
int NO_INDEXB, NO_BLOCKB, NO_TAGB;

cout << "Please enter Block Size: " << '\n';
cin >> BLOCKSIZE;
cout << " Please enter size: " << '\n';
cin >> SIZE;
cout << " Please enter Associativity: " << '\n';
cin >> ASSOC;

NO_SETS = SIZE / (ASSOC * BLOCKSIZE);
// cout << "No of Sets: " << NO_SETS << '\n';

NO_INDEXB = int(log2(NO_SETS));
// cout << NO_INDEXB <<endl;

NO_BLOCKB = int(log2(BLOCKSIZE));
// cout << NO_BLOCKB <<endl;

NO_TAGB = BLOCKSIZE - NO_INDEXB - NO_BLOCKB;
// cout << NO_TAGB <<endl;

Cache* myCache;
myCache = new Cache[NO_SETS];
for (i = 0; i < NO_SETS; i++)
myCache[i] = new Cache[ASSOC];

for (i = 0; i < NO_SETS; i++) {
for (j = 0; j < ASSOC; j++) {
myCache[i][j].tag = new char(NO_TAGB + 1);
for (k = 0; k < NO_TAGB; k++) {
myCache[i][j].tag[k] = '0';
}
myCache[i][j].LRU = j;
myCache[i][j].valid = 0;
myCache[i][j].dirty = 0;
myCache[i][j].index = i;
}
}

最佳答案

Cache* myCache;

myCache[i][j].LRU = j;

myCache[i][j] 是什么意思

关于c++ - '*(myCache + ((long unsigned int)(((long unsigned int)i) * 32ul))) 中的 ‘operator=’ 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25880834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com