Hi,
i'm new with c++, and this is my first overloading
in the last line of this .h file (marked), the compiler desagrees.
it says:
Code:
error C2143: syntax error : missing ';' before '&'
error C2433: 'ostream' : 'friend' not permitted on data declarations
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
now, when i add "std:stream&" instead of "ostream&, i get:
Code:
error C2270: '<<' : modifiers not allowed on nonmember functions
the file: (error line is marked)
Code:
//Graph.h
#ifndef _GRAPH_
#define _GRAPH_
#include <iostream>
/**************FORWARD DECLERATIONS******************************************/
class LinkedList;
class EdgeNode;
class Edge;
class Vertex;
class Node;
class EdgeList;
/*********************END OF FORWARD DECLARATIONS***************************/
class Graph
{
private:
LinkedList *m_list;
int m_countVer;
public:
//locate edge. return pointer to location or NULL (if not found)
EdgeNode* findEdge (const int &source,const int &dest)const;
//find vertex (by id value)
Node* findVer (const int & id)const;
//find vertex (by vertex)
Node* findVer (const Vertex &)const;
//Ccot
Graph(const Graph & g2);
//ctor
Graph();
//dtor
~Graph();
//add vertex to graph (check if not exist first)
void addVer(const Vertex & v1);
//add edge to graph, add vertexes if not exist
void addEd(const int & sourceId, const int & destSource);
//delete vertex (argument- vertex)
void delVer(const Vertex & v1);
//delete edge.
void delEd(const Edge & ed1);
//delete edges (by id)
void delEd(const int & source,const int & dest);
//operator union
Graph operator+ (const Graph & g2) const ;
//operator Intersection
Graph operator- (const Graph & g2)const;
//operator - unary - complement
Graph operator- () const;
//operator equal and opposite
bool operator == (const Graph & g2) const;
bool operator != (const Graph & g2) const {return !((*this)==g2);};
//operator print
friend ostream& operator <<(ostream & os,const Graph & g2)const; // <--ERROR
};
#endif