C++ 应为标识符c++;

C++ 应为标识符c++;,c++,class,priority-queue,C++,Class,Priority Queue,我正在尝试编写一个类,并最终将其编译,但VisualStudio仍然显示有错误(带有红线) 问题在于(我在VisualStudio画红线的地方写了@problem here@): 1。const priority_queue@*CM::getHeavyHitters(){ 2.返回和重量级投手; 3. } 上面写着: “错误:需要标识符”(在第一行) 错误:标识符“heavyHitters”未定义(在第二行) 第一个问题我完全不明白。第二个我不明白,因为heavyHitters是CM的成员,我

我正在尝试编写一个类,并最终将其编译,但VisualStudio仍然显示有错误(带有红线)

问题在于(我在VisualStudio画红线的地方写了@problem here@):

1。const priority_queue@*CM::getHeavyHitters(){
2.返回和重量级投手;
3. }
上面写着:

  • “错误:需要标识符”(在第一行)
  • 错误:标识符“heavyHitters”未定义(在第二行)
  • 第一个问题我完全不明白。第二个我不明白,因为heavyHitters是CM的成员,我包括CM

    顺便说一句,我试图建立。它没有解决问题

    谢谢

    整个代码如下:


    Count Min Sketch.cpp

    #include "Count-Min Sketch.h"
    
    
    CM::CM(double eps, double del) {
    
    }
    
    void CM::update(int i, int long unsigned c) {
    
    }
    
    int long unsigned CM::point(int i) {
        int min = count[0][calcHash(0,i)];
    
        return min;
    }
    
    const priority_queue<int,vector<int>,greater<int>>* CM::getHeavyHitters() {
        return &heavyHitters;
    }
    
    CM::CM(const CM &) {
    
    }
    
    CM::~CM() {
    
    }
    
    
    int CM::calcHash(int hashNum, int inpt) {
        int a = hashFunc[hashNum][0];
        int b = hashFunc[hashNum][1];
        return ((a*inpt+b) %p) %w;
    }
    
    bool CM::isPrime(int a) {
        bool boo = true;
    
        return boo;
    }
    
    int CM::gePrime(int n) {
        int ge = 2;
    
        return ge;
    }
    
    #包括“Count Min Sketch.h”
    CM::CM(双eps,双del){
    }
    void CM::update(int i,int long unsigned c){
    }
    int长无符号CM::point(int i){
    int min=计数[0][calcHash(0,i)];
    返回最小值;
    }
    const priority_queue*CM::getHeavyHitters(){
    回归与重量级作家;
    }
    厘米::厘米(常数厘米&){
    }
    厘米::~厘米(){
    }
    intcm::calcHash(inthashnum,intinpt){
    int a=hashFunc[hashNum][0];
    int b=hashFunc[hashNum][1];
    返回((a*inpt+b)%p)%w;
    }
    boolcm::isPrime(inta){
    bool boo=真;
    返回boo;
    }
    int-CM::gePrime(int-n){
    int ge=2;
    返回ge;
    }
    

    计数Min.h

    #pragma once
    
    #ifndef _CM_H
    #define _CM_H
    
    using namespace std;
    #include <queue>
    
    class CM {
    private:
        // d = ceiling(log(3,1/del)), w = ceiling(3/eps)
        int d,w,p; 
        // [d][w]
        int long unsigned *(*count); 
        // [d][2]
        int *(hashFunc[2]); 
        // initialized to 0. norm = sum(ci)
        int long unsigned norm; 
        // Min heap
        priority_queue<int,vector<int>,greater<int>> heavyHitters;
    
        // ((ax+b)mod p)mod w
        int calcHash(int hashNum, int inpt);
        // Is a a prime number
        bool isPrime(int a);
        // Find a prime >= n
        int gePrime(int n); 
    
    public:
        // Constructor
        CM(double eps, double del);
        // count[j,hj(i)]+=c for 0<=j<d, norm+=c, heap update & check
        void update(int i, int long unsigned c);
        // Point query ai = minjcount[j,hj(i)]
        int long unsigned point(int i); 
        const priority_queue<int,vector<int>,greater<int>>* getHeavyHitters();
        // Copy constructor
        CM(const CM &);
        // Destructor
        ~CM();
    };
    
    #endif // _CM_H
    
    #pragma一次
    #ifndef\u CM\u H
    #定义_CM_H
    使用名称空间std;
    #包括
    CM类{
    私人:
    //d=天花板(对数(3,1/del)),w=天花板(3/eps)
    int d,w,p;
    //[丁][西]
    int长无符号*(*计数);
    //[丁][2]
    int*(hashFunc[2]);
    //初始化为0。范数=总和(ci)
    int长无符号范数;
    //最小堆
    优先队列重量级选手;
    //((ax+b)模块p)模块w
    int-calcHash(int-hashNum,int-inpt);
    //是一个素数
    bool-isPrime(inta);
    //找到一个素数>=n
    int-gePrime(int-n);
    公众:
    //建造师
    CM(双eps,双del);
    
    //count[j,hj(i)]+=c表示0
    是单个标记,即右移(或提取)运算符。某些编译器在嵌套模板专门化中无法正确识别它。您必须在两个尖括号之间放置一个空格,如下所示:

    Type<specType<nestedSpecType> > ident;
                                ^^^
    
    类型识别;
    ^^^
    
    <代码> > C++ > .A.S.ROMA,我不想这样。我想返回CM的私有成员,称为重量级。您依赖于<代码> <代码>,也包括<代码> <代码>和<代码> <代码>(对于<代码>更大< /代码>)。总是显式地包含您需要的内容是一种很好的做法。试着看看它是否有什么不同。
    int*(hashFunc[2]);
    是一个由两个
    int*
    s组成的数组。您是不是想用函数数组指针来代替呢?谢谢,我添加了显式声明。但是没有帮助。还有int*(hashFunc[2])应该是一个二维数组[d][2],我将动态分配它。我仔细检查了一下,实际上我想我应该将它改为int(*hashFunc)[2]。谢谢:)它没有帮助。不过谢谢你的尝试
    Type<specType<nestedSpecType> > ident;
                                ^^^