hi every1 i have this code which is delete a node in the graph
but there is 5 errors and 1 warning I need u to help me with this errors

#include<iostream>
using namespace std;
template<class TYPE>
struct Vertex;
template<class TYPE>
struct Arc;

template<class TYPE>
struct Vertex
{
	Vertex<TYPE> *pNextVertex;
	TYPE    data;
	int inDegree;
	int outDegree;
	short processed;
	Arc<TYPE> *pArc;
};//VERTEX


template<class TYPE>
struct Arc
{
	Vertex<TYPE>  *destination;
	Arc<TYPE>     *pNextArc;
};//ARC


template<class TYPE, class KTYPE>
class Graph
{
	private:
		int count;
		Vertex<TYPE>  *first;
	public:
		Graph (void);
		~Graph (void);
		int insertVertex (TYPE dataIn);
		int deleteVertex (KTYPE dltKey);
		int insertArc (KTYPE fromKey,KTYPE toKey);
		int deleteArc (KTYPE fromKey,KTYPE toKey );
};


/*	=============== insertVertex  ============== 
	This function insert new data into the graph.
	   Pre   dataIn contain data to be inserted
	   Post  data have been inserted or memory overflow
	   Return 1 if succeful; -1 if memory overflow
*/


template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::insertVertex (TYPE dataIn)
{
	Vertex<TYPE> *newPtr;
	Vertex<TYPE> *locPtr;
	Vertex<TYPE> *predPtr;

	newPtr=new Vertex<TYPE>;
	if(newPtr)
	{
		newptr->pNextVertex=NULL;
		newptr->data=dataIn;
		newptr->inDegree =0;
		newptr->outDegree =0;
		newptr->processed =0;
		newptr->pArc=NULL;
		count++;
	}
	else
		return -1;
	locPtr=first;
	if(!locPtr)
		first=newptr;
	else
	{
		predPtr=NULL;
		while(locPtr&&data.key>(locPtr->data).key)
		{
			predPtr=locPtr;
			locPtr=locPtr->pNextVertex;
		}
		if(!predPtr)
			first=newptr;
		else
			predPtr->pNextVertex=newptr;
		newptr->pNextVertex=locptr;
	}
	return 1;
}

/*	=============== insertArc  ============== 
	This function add an arc vertex between to vertices.
	   Pre   fromKey is key of start vertex.
	         toKey is key of destination vertex
	   Post  arc have been added to adjency list
	   Return 1 if succeful; -1 if memory overflow;
	         -2 if fromKey not found ;-3 if toKey not found
*/
template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::insertArc (KTYPE fromKey , KTYPE toKey)
{
	Arc<TYPE> *newPtr;
	Arc<TYPE> *arcPredPtr;
	Arc<TYPE> *arcWalkPtr;

    Vertex<TYPE> *vertFromPtr;
	Vertex<TYPE> *vertToPtr;

	newptr=new Arc<TYPE>;
	if(!newPtr)
		return -1;
	vertFromPtr=first;
	while(vertFromPtr&&fromKey>(vertFromPtr->data).key)
		vertFromPtr=vertFromPtr->pNextVertex;
	if(!vertFromPtr||fromKey!=(vertFromPtr->data).key)
		return -2;
	vertToPtr=first;
	while(vertToPtr&&toKey>(vertToPtr->data).key)
			vertToPtr=vertToPtr->pNextVertex;
	if(!vertToPtr||toKey!=(vertToPtr->data).key)
		return -3;
	++vertFromPtr->outDegree;
	++vertToPtr->inDegree;
    newptr->destination=vertToPtr;
	if(!vertFromPtr->pArc)
	{
		vertFromPtr->pArc=newptr;
		newptr->pNextArc=NULL;
		return 1;
	}
		arcPredPtr=NULL;
		arcWalkPtr=vertFromPtr->pArc;
		while(arcWalkPtr&&toKey>=(arcWalkPtr->destination->data.key))
		{
			arcPredPtr=arcWalkPtr;
			arcWalkPtr=arcWalkPtr->pNextPtr;
		}
		if(!arcPredPtr)
			vertFromPtr->pArc=newptr;
		else
			arcPredPtr->pNextArc= newptr;
		newptr->pNextArc=arcWalkPtr;
		return  1;
	}

/*	=============== deleteARC  ============== 
	This function delete vertex only if its degree 0.
	   Pre   dltKey is the Key 
	   Post  data have been inserted or memory overflow
	   Return 1 if succeful; -1 if memory overflow
*/


template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::deleteArc (KTYPE fromKey,KTYPE toKey)
{
	Vertex<TYPE> *fromVertexPtr;
	Vertex<TYPE> *toVertexPtr;
	Arc<TYPE> *arcWalkPtr;
	Arc<TYPE> *preArcPtr;
	if(!first)
	
		return -2;
	fromVertexPtr=first;
	while(fromVertexPtr&&fromKey>(fromVertexPtr->data).key)
		fromVertexPtr=fromVertexPtr->pNextVertex;
	if(!fromVertexPtr||fromKey!=(fromVertexPtr->data).key)
	if(!fromVertexPtr->pArc)
		return -3;
	preArcPtr=NULL;
	arcWalkPtr=fromVertexPtr->pArc
while(arcWalkPtr&&toKey>(arcWalkPtr->destination->data).key)
{
    preArcPtr=arcWalkPtr;
	arcWalkPtr=arcWalkPtr->pNextArc;
}
if(!arcWalkPtr||toKey!=(arcWalkPtr->destination->data.key))
      return -3;
toVertexPtr=arcWalkPtr->destination;
--fromVertexPtr->outDegree;
--toVertexPtr->inDegree;
if(!preArcPtr)
    fromVertexPtr->pArc=arcWalkPtr->pNextArc;
else
    preArcPtr->pNextArc=arcWalkPtr->pNextArc;
delete arcWalkPtr;
return 1;
}

/*	=============== deleteVertex  ============== */
template<class TYPE,class KTYPE>
int Graph<TYPE,KTYPE>::deleteVertex(KTYPE dltKey)
{
	Vertex<Type>  *predPtr;
	Vertex<Type>  *walkPtr;
	if(!first)
		return -2;
	predPtr=NULL;
    walkPtr=first;
	while(walkPtr&&dltKey>(walkPtr->data).key)
	{
		predPtr=walkPtr;
        walkPtr=walkPtr->pNextVertex;
	}
	if(!walkPtr||dltKey!=(walkPtr->data.key))
		return -2;
	if(!predPtr)
		first = walkPtr->pNextVertex;
	else
		predPtr->pNextVertex=walkPtr->pNextVertex;
	count--;
	deleteArc(key);
	delete walkPtr;
	return 1;
}


	
/*==============VERTEX Struct==============*/

struct VERTEX 
{
	int data_v;
};  
/*==============ARC Struct==============*/

struct ARC 
{
	int data_a;
};

/*============insert_v==========================*/
void insert_v(Graph<VERTEX,ARC>&graph)
{
bool vert;
VERTEX ver;
cout<<"Enter the data/n";
cin>>ver.data_v;
vert=graph.insertVertex(ver);

}
/*============insert_a==========================*/
void insert_a(Graph<VERTEX,ARC>&graph)
{
bool vert;
ARC arc;
VERTEX ver;
cout<<"Enter the vertex/n";
cin>>ver.data_v;
cout<<"Enter the data/n";
cin>>arc.data_a;
vert=graph.insertArc(arc);

}
/*============delete_v==========================*/
void delete_v(Graph<VERTEX,ARC>&graph)
{
VERTEX ver;
	bool vert;

cout<<"Enter the data/n";
cin>>ver.data_v;
vert=graph.deleteVertex(ver);

}
/*============main==========================*/
int main()
{  
Graph<VERTEX,ARC>&graph;
	int choice;
	bool valid;
	//int data_v;
	//int data_a;
	
		cout<<"***************MENU**********************"<<endl;
	     cout  << "1. Insert vertex.\n"
			    <<"2. Insert arc.\n" 
               <<"3. delete node.\n"
		       <<"4. Exit\n";

cout<<"ENTER YOUR CHOICE"<<endl;
do{
	
	cin>>choice;
	switch(choice)
	{
	
	case 1:
		cout<<"Enter/n";
			cin>>data_v;
       insert_v(data_v);
     break;
	case 2:
		cout<<"Enter/n";
			cin>>data_a;
       insert_a(data_a);
			break;
	case 3:
		cout<<"Enter/n";
			cin>>data_v;
      delete_v(data_v);
		break;
	case 4:
			exit(1);
			break;	
	}//switch
}while(choice!=4);
 
	

 return 0;
}

The error:

delete.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(657) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(670) : error C2660: 'insertArc' : function does not take 1 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(681) : error C2664: 'deleteVertex' : cannot convert parameter 1 from 'struct VERTEX' to 'struct ARC'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(687) : error C2530: 'graph' : references must be initialized
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(708) : error C2065: 'data_v' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(713) : error C2065: 'data_a' : undeclared identifier
Error executing cl.exe.

Something tells me you've found someone else's code, and you're attempting to use it without having a clue what it actually does. I hope this isn't your homework ;)

Studio\MyProjects\delete_v\delete.cpp(670) : error C2660: 'insertArc' : function does not take 1 parameters

The compiler is telling you that you've called the function insertArc() on line 670, but you've passed the wrong number of parameters - you need to pass 1 parameter, or change the function (or overload it) to take the parameters you need.

Studio\MyProjects\delete_v\delete.cpp(681) : error C2664: 'deleteVertex' : cannot convert parameter 1 from 'struct VERTEX' to 'struct ARC'

the compiler is telling you that the first input parameter of the deleteVertex() function must be of the type struct ARC. the object you're passing to it on line 681 is of the type struct VERTEX

C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(687) : error C2530: 'graph' : references must be initialized

This one is self explanatory - you declared graph as a reference, but you've left it dangling. The compiler is telling you that references must be initialised - meaning you need to 'point' it to something.

C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(708) : error C2065: 'data_v' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(713) : error C2065: 'data_a' : undeclared identifier

You're trying to use the names data_a and data_v without declaring them anywhere... it looks like you had them, and commented them out.

thanks i have correct some of them but still there are 4 errors ,2 warnings

#include<iostream.h>
template<class TYPE>
struct Vertex;
template<class TYPE>
struct Arc;
 
template<class TYPE>
struct Vertex
{
    Vertex<TYPE> *pNextVertex;
    TYPE data;
    int inDegree;
    int outDegree;
    short processed;
    Arc<TYPE> *pArc;
};//VERTEX
 
 
template<class TYPE>
struct Arc
{
    Vertex<TYPE> *destination;
    Arc<TYPE> *pNextArc;
};//ARC
 
 
template<class TYPE, class KTYPE>
class Graph
{
    private:
        int count;
        Vertex<TYPE> *first;
    public:
        Graph (void);
        ~Graph (void);
        int insertVertex (TYPE dataIn);
        int deleteVertex (KTYPE dltKey);
        int insertArc (KTYPE fromKey,KTYPE toKey);
        int deleteArc (KTYPE fromKey,KTYPE toKey );
};
 
 
/*    =============== insertVertex ============== 
    This function insert new data into the graph.
     Pre dataIn contain data to be inserted
     Post data have been inserted or memory overflow
     Return 1 if succeful; -1 if memory overflow
*/
 
 
template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::insertVertex (TYPE dataIn)
{
    Vertex<TYPE> *newPtr;
    Vertex<TYPE> *locPtr;
    Vertex<TYPE> *predPtr;
 
    newPtr=new Vertex<TYPE>;
    if(newPtr)
    {
        newptr->pNextVertex=NULL;
        newptr->data=dataIn;
        newptr->inDegree =0;
        newptr->outDegree =0;
        newptr->processed =0;
        newptr->pArc=NULL;
        count++;
    }
    else
        return -1;
    locPtr=first;
    if(!locPtr)
        first=newptr;
    else
    {
        predPtr=NULL;
        while(locPtr&&data.key>(locPtr->data).key)
        {
            predPtr=locPtr;
            locPtr=locPtr->pNextVertex;
        }
        if(!predPtr)
            first=newptr;
        else
            predPtr->pNextVertex=newptr;
        newptr->pNextVertex=locptr;
    }
    return 1;
}
 
/*    =============== insertArc ============== 
    This function add an arc vertex between to vertices.
     Pre fromKey is key of start vertex.
     toKey is key of destination vertex
     Post arc have been added to adjency list
     Return 1 if succeful; -1 if memory overflow;
     -2 if fromKey not found ;-3 if toKey not found
*/
template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::insertArc (KTYPE fromKey , KTYPE toKey)
{
    Arc<TYPE> *newPtr;
    Arc<TYPE> *arcPredPtr;
    Arc<TYPE> *arcWalkPtr;
 
Vertex<TYPE> *vertFromPtr;
    Vertex<TYPE> *vertToPtr;
 
    newptr=new Arc<TYPE>;
    if(!newPtr)
        return -1;
    vertFromPtr=first;
    while(vertFromPtr&&fromKey>(vertFromPtr->data).key)
        vertFromPtr=vertFromPtr->pNextVertex;
    if(!vertFromPtr||fromKey!=(vertFromPtr->data).key)
        return -2;
    vertToPtr=first;
    while(vertToPtr&&toKey>(vertToPtr->data).key)
            vertToPtr=vertToPtr->pNextVertex;
    if(!vertToPtr||toKey!=(vertToPtr->data).key)
        return -3;
    ++vertFromPtr->outDegree;
    ++vertToPtr->inDegree;
newptr->destination=vertToPtr;
    if(!vertFromPtr->pArc)
    {
        vertFromPtr->pArc=newptr;
        newptr->pNextArc=NULL;
        return 1;
    }
        arcPredPtr=NULL;
        arcWalkPtr=vertFromPtr->pArc;
        while(arcWalkPtr&&toKey>=(arcWalkPtr->destination->data.key))
        {
            arcPredPtr=arcWalkPtr;
            arcWalkPtr=arcWalkPtr->pNextPtr;
        }
        if(!arcPredPtr)
            vertFromPtr->pArc=newptr;
        else
            arcPredPtr->pNextArc= newptr;
        newptr->pNextArc=arcWalkPtr;
        return 1;
    }
 
/*    =============== deleteARC ============== 
    This function delete vertex only if its degree 0.
     Pre dltKey is the Key 
     Post data have been inserted or memory overflow
     Return 1 if succeful; -1 if memory overflow
*/
 
 
template <class TYPE, class KTYPE>
int Graph<TYPE,KTYPE>::deleteArc (KTYPE fromKey,KTYPE toKey)
{
    Vertex<TYPE> *fromVertexPtr;
    Vertex<TYPE> *toVertexPtr;
    Arc<TYPE> *arcWalkPtr;
    Arc<TYPE> *preArcPtr;
    if(!first)
 
        return -2;
    fromVertexPtr=first;
    while(fromVertexPtr&&fromKey>(fromVertexPtr->data).key)
        fromVertexPtr=fromVertexPtr->pNextVertex;
    if(!fromVertexPtr||fromKey!=(fromVertexPtr->data).key)
    if(!fromVertexPtr->pArc)
        return -3;
    preArcPtr=NULL;
    arcWalkPtr=fromVertexPtr->pArc
while(arcWalkPtr&&toKey>(arcWalkPtr->destination->data).key)
{
preArcPtr=arcWalkPtr;
    arcWalkPtr=arcWalkPtr->pNextArc;
}
if(!arcWalkPtr||toKey!=(arcWalkPtr->destination->data.key))
return -3;
toVertexPtr=arcWalkPtr->destination;
--fromVertexPtr->outDegree;
--toVertexPtr->inDegree;
if(!preArcPtr)
fromVertexPtr->pArc=arcWalkPtr->pNextArc;
else
preArcPtr->pNextArc=arcWalkPtr->pNextArc;
delete arcWalkPtr;
return 1;
}
 
/*    =============== deleteVertex ============== */
template<class TYPE,class KTYPE>
int Graph<TYPE,KTYPE>::deleteVertex(KTYPE dltKey)
{
    Vertex<Type> *predPtr;
    Vertex<Type> *walkPtr;
    if(!first)
        return -2;
    predPtr=NULL;
walkPtr=first;
    while(walkPtr&&dltKey>(walkPtr->data).key)
    {
        predPtr=walkPtr;
walkPtr=walkPtr->pNextVertex;
    }
    if(!walkPtr||dltKey!=(walkPtr->data.key))
        return -2;
    if(!predPtr)
        first = walkPtr->pNextVertex;
    else
        predPtr->pNextVertex=walkPtr->pNextVertex;
    count--;
    deleteArc(key);
    delete walkPtr;
    return 1;
}
 
 
 
/*==============VERTEX Struct==============*/
 
struct VERTEX 
{
    int data_v;
}; 
/*==============ARC Struct==============*/
 
struct ARC 
{
    int data_a;
};
 
/*============insert_v==========================*/
void insert_v(Graph<VERTEX,ARC>&graph)
{
bool vert;
VERTEX ver;
cout<<"Enter the data/n";
cin>>ver.data_v;
vert=graph.insertVertex(ver);
 
}
/*============insert_a==========================*/
void insert_a(Graph<VERTEX,ARC>&graph)
{
bool vert;
ARC arc;
VERTEX ver;
cout<<"Enter the vertex/n";
cin>>ver.data_v;
cout<<"Enter the data/n";
cin>>arc.data_a;
vert=graph.insertArc(ver,arc);
 
}
/*============delete_v==========================*/
void delete_v(Graph<VERTEX,ARC>&graph)
{
VERTEX ver;
ARC arc;
bool vert;
 
cout<<"Enter the data/n";
cin>>arc.data_a;
vert=graph.deleteVertex(arc);
 
}
/*============main==========================*/
int main()
{ 
Graph<VERTEX,ARC>graph;
 
    int choice;
    bool valid;
VERTEX ver;
ARC arc;
 
        cout<<"***************MENU**********************"<<endl;
     cout << "1. Insert vertex.\n"
             <<"2. Insert arc.\n" 
<<"3. delete node.\n"
         <<"4. Exit\n";
 
cout<<"ENTER YOUR CHOICE"<<endl;
do{
 
    cin>>choice;
    switch(choice)
    {
 
    case 1:
insert_v(ver);
break;
    case 2:
 
insert_a(ver,arc);
            break;
    case 3:
 
delete_v(arc);
        break;
    case 4:
            exit(1);
            break;    
    }//switch
}while(choice!=4);
 
 
 
return 0;
}

errors:
Compiling...
delete.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(657) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(670) : error C2664: 'insertArc' : cannot convert parameter 1 from 'struct VERTEX' to 'struct ARC'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(682) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(709) : error C2664: 'insert_v' : cannot convert parameter 1 from 'struct VERTEX' to 'class Graph<struct VERTEX,struct ARC> &'
A reference that is not to 'const' cannot be bound to a non-lvalue
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(713) : error C2660: 'insert_a' : function does not take 2 parameters
C:\Program Files\Microsoft Visual Studio\MyProjects\delete_v\delete.cpp(717) : error C2664: 'delete_v' : cannot convert parameter 1 from 'struct ARC' to 'class Graph<struct VERTEX,struct ARC> &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Error executing cl.exe.

delete.exe - 4 error(s), 2 warning(s)

If you're going to carry on using code which someone else has written to base your program on, then make some effort to understand how to use it. Have you even read the errors the compiler gives you for yourself? The errors you've pasted aren't exactly hard to understand.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.