Insertion in Hashtable

Hey, please help me identify the mistake. It is showing segmentation fault.

#include<iostream>
using namespace std;

template<typename T>
class node{
public:
    string key;
    T value;
    node *next;
    // constructor
    node(string k, int v){
        key = k;
        value = v;
        next = NULL;
    }
};

template<typename T>
class hashtable{
public:
    node<T> **table;
    int cs;
    int ts;
    // constructor
    hashtable(int t=7){
        ts=7;
        new node<T>*[ts];
        cs = 0;
        for(int i=0; i<ts; i++){
            table[i] = NULL;
        }
    }

    int hash_func(string key){
        int idx = 0;
        int p = 1;
        for(int i=0; i<key.length(); i++){
            idx = idx + ((p*key[i])%ts);
            idx = idx%ts;
            p = 27*p%ts;
        }
        return idx;
    }


    // insertion
    void insert(string key, int value){
        int idx = hash_func(key);   // generate idx corresponding to key
        node<T> *temp = new node<T>(key,value);
        temp->next = table[idx];
        table[idx] = temp;
        cs++;
    }


    // print
    void print(){
        for(int i=0; i<ts; i++){
            node<T> *temp = table[i];
            while(temp){
                cout<<"Key: "<<temp->key<<", Value: "<<temp->value<<" ";
                temp = temp->next;
            }cout<<endl;
        }
    }


};


int main(){

    hashtable<int> price_menu;
    price_menu.insert("Burger",120);
    price_menu.insert("Pepsi",20);
    price_menu.insert("BurgerPizza",150);
    price_menu.insert("Noodles",25);
    price_menu.insert("Coke",40);

    price_menu.print();


    return 0;
}

run error because of this line
correct statement is p = (27*p)%ts;

also i have observed one another mistake

it should be ts = t;

hey, can you please check it again. Because after making these two changes, it is still showing seg fault.

yes i forgot to mention one mistake

what is this you have to write it
table = new node*[ts];

after these changes code runs

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.