Ella Sharakanski
Ella Sharakanski

Reputation: 2773

expected an identifier c++

I am trying to write a class and I finally got it to compile, but visual studio still shows there are errors (with a red line).

The problem is at (I wrote @problem here@ around the places where visual studio draws a red line):

1. const priority_queue<int,vector<int>,greater<int> @>@ * CM::getHeavyHitters() {
2.     return & @heavyHitters@ ;
3. }

And it says:

  1. "Error: expected an identifier" (at the first line)
  2. "Error: identifier "heavyHitters" is undefined" (at the second line)

The first problem I don't understand at all. The second one I don't understand because heavyHitters is a a member of CM and I included CM.

BTW, I tried to build. It didn't fix the problem.

Thanks!!!

The whole code is here:


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

#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

Upvotes: 0

Views: 5268

Answers (1)

user529758
user529758

Reputation:

>> is a single token, the right-shift (or extraction) operator. Some compilers don't recognize it correctly in nested template specialization. You have to put a space between the two angle brackets like this:

Type<specType<nestedSpecType> > ident;
                            ^^^

Upvotes: 1

Related Questions