C++ 与‘不匹配;运算符=’;在‘*(myCache+;((长无符号整数)((长无符号整数)i)*32ul)))

C++ 与‘不匹配;运算符=’;在‘*(myCache+;((长无符号整数)((长无符号整数)i)*32ul))),c++,linux,C++,Linux,我不断收到以下错误: 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

我不断收到以下错误:

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;
        }
    }
intmain(){
int ASSOC,块大小,无集合,大小,i,k,l,j;
int无索引,无块,无标记;
cout块大小;
cout大小;
库特协会;
无集合=大小/(关联*块大小);
//库特

myCache[i][j]
的意思是什么?至少你应该展示一下
Cache
是如何定义的。分别使用
std::vector
std::vector
。嘿,我得到了itCache**myCache;myCache=new Cache*[NO_set];for(i=0;iIt似乎你打算
myCache
成为一个二维数组?
Cache* myCache;

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