I got two classes "DTreeEmbedder" and "modifier". Embedder is a template class and I want to manipulate member variables of "DTreeEmbedder".
class DTreeEmbedder:
class modifier; //forward declaration of modifier
using namespace ogdf;
using namespace ogdf::energybased::dtree;
template<int Dim>
class DTreeEmbedder
{
public:
//! constructor with a given graph, allocates memory and does
initialization
explicit DTreeEmbedder(GLFWwindow * w, const Graph& graph);
//! destructor
virtual ~DTreeEmbedder();
modifier* m_modifier;
In constructor
template<int Dim>
DTreeEmbedder<Dim>::DTreeEmbedder(GLFWwindow * w, const Graph& graph) :
m_graph(graph)
{
m_modifier = new modifier();
}
Both objects need access to each other, therefore the forward declaration.
#pragma once
#include "DTreeEmbedder.h"
class modifier
{
public:
modifier(DTreeEmbedder<int>* e);
~modifier();
DTreeEmbedder<int>* m_embedder;
void pca_project(int pc1,int pc2);
};
pca_project is a function that should change values / call functions in m_embedder
In constructor of modifier:
modifier::modifier(DTreeEmbedder<int>* e)
{
m_embedder = e;
}
pca function:
void modifier::pca_project(int pc1, int pc2)
{
m_embedder->stop();
}
My approach therefore is:
- Create DTreeEmbedder
- DTreeEmbedder creates modifier with pointer of itself
- modifier got the pointer to DTreeEmbedder and can now change values of that object
My errors are:
"int": Invalid type for the non-type template parameter "Dim"
This pointer can not be converted from "DTreeEmbedder" to "DTreeEmbedder <Dim> &"
Thx in advance