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

标签 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: 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/

相关文章:

c++ - Linux 上 UDP 的延迟测量

c++ - C++中引用变量的使用

c++ - 如何创建一个空的 DOMElement

c++ - 如何让FLTK 1.3.0在Ubuntu Linux中支持中文?

c++ - 在 VST 中发送和接收 UDP

c++ - 尽可能传递 const 引用参数

linux - Java 1.8.0_77 中的 Linux 上缺少 jfxrt.jar

windows - 安装服务器(在 Windows 上)和客户端工具(在 Windows、Linux 和 Apple 上)以进行版本控制

linux - 命令(wget)从存储库网站获取所有带有 rpm 扩展名的文件

c - 如何在多个显示器上使用 XGetImage?