Adjacency matrix of graph in c++ ( getting error while using malloc ) :     #include <iostream>
    #include <cstdlib>
    using namespace std;

    class graph{
    int v,e,**adj;
    public:
    graph();
     };

    graph::graph(){
    graph *g = (graph*)malloc(sizeof(graph));
    if(g){
    cout << " error";
    exit(1);
    }
    int u,V,i;
    cout << "Enter no of nodes and edges ? ";
    cin  >> g->v ;
    cin >> g->e ;
    g->adj = (int**)malloc(sizeof(int) * sizeof(g->v * g->v ));
    for(u = 0 ; u <= g->v ; u++)
    for(V = 0 ; V <= g->v ; V++ )
    g->adj[u][V] = 0;
    cout << " Enter connections ? ";
    for(i = 0 ; i  <= g->e ; i++){
    cin >> u ;
    cin >> V ;
    g->adj[u][V] = 1;
    g->adj[V][u] = 1;
    }
    cout << g;
    }
    int main(){

    graph a;
    return 0;
    }
I am trying to figure out whats the problem but unable to resolve by myself . please help !
i've researched for about 2 hours over this topic  unfortunately did't found any 
proper help desk.
i am learning data structure and implementing in c++ language.
if you could able to advice me 
that'd be earnestly kind of you .
thanks !


                                                                                                             
                                      

                                                                  
