Для личного проекта я хочу создать общий график.
Я создал 2 класса: класс OrientedNode и класс ClassicArrow.
Вот файл класса:
-Node Class File
#pragma once
#include <iostream>
#include <vector>
//BEGIN OF THE CLASS CLASSICNODE:MOTHER CLASS OF EVERY TYPE OF NODE
class ClassicNode{
protected:
unsigned int nodeId;
public:
//Constructor
ClassicNode();
ClassicNode(unsigned int NodeId);
//Getters
unsigned int getId()const;
//Operator
friend std::ostream& operator<<(std::ostream& outputStream, const ClassicNode& N){
return outputStream << N.getId()<<std::endl;
}
bool operator ==(const ClassicNode& N);
};
//BEGIN OF THE CLASS ORIENTEDNODE:
// -IT INHERITS THE CLASS NODE
// -IT REPRESENTS THE NODE IN A ORIENTED GRAPHE
template <typename ARROW> class OrientedNode: public ClassicNode{
protected:
std::vector<ARROW> listArrowsIn;
std::vector<ARROW> listArrowsOut;
public:
//Constructor
OrientedNode();
OrientedNode(unsigned int NodeId);
//Getter
std::vector<ARROW> getListArrowIn()const;
std::vector<ARROW> getListArrowOut()const;
//Manipulation
void addArrowIn(const ARROW& A);
void addArrowOut(const ARROW& A);
};
- файл класса дуги:
#pragma once
#include <iostream>
template <typename NODE> class ClassicArrow
{
protected:
unsigned int origineNodeId;//Id of the node where the arrow begin
unsigned int destinationNodeId;//Id of the node where the arrow end
float distance;
NODE* targetNode;//Pointer to the node where the arrow end
public:
//Constructor
ClassicArrow();
ClassicArrow(const ClassicArrow<NODE>& A);
ClassicArrow(unsigned int OrigineNodeId,unsigned int DestinationNodeId,float Distance,NODE* TargetNode);
//Getters
unsigned int getOrigineNodeId()const;
unsigned int getDestinationNodeId()const;
float getDistance()const;
NODE* getTargetNode()const;
//Operator
void operator=(const ClassicArrow<NODE>& A);
NODE& operator*(void);
friend std::ostream& operator<<(std::ostream& outputStream, const ClassicArrow<NODE>& A){
return outputStream <<"IdBegin="<<A.getOrigineNodeId()<< "IdEnd="<<A.getDestinationNodeId()<<"distance="<<A.getDistance()<<std::endl;
}
};
Класс OrientedNode и класс ClassicArrow вложены вместе.
Я хочу объявить переменную OrientedNode с параметром класса шаблона ClassicArrow (ligne для файла в основном файле). Как я могу это сделать?
#include <iostream>
#include <vector>
#include "ClassicArrow.h"
#include "ClassicNode.h"
int main() {
//Code for a Oriented Node variable declaration
}