I'm getting two errors in my .cc file, one is that the function declaration is incompatible with the one declared in the .h file. The other error is that it can't return to an incomplete class. I'm assuming both of these have to do with the same problem, but I haven't been able to figure out what's actually going wrong here.
reg.h
#ifndef REG_H
#define REG_H
class REG
{
private:
struct REG_node
{
struct REG_node *first_neighbor;
char first_label;
struct REG_node *second_neighbor;
char second_label;
};
public:
struct REG_graph
{
struct REG_node *start;
struct REG_node *accept;
};
struct REG_graph createREG(char input);
};
#endif
reg.cc
#include "reg.h"
struct REG_graph REG::createREG(char input)
{
struct REG_node node1 = {nullptr, input, nullptr, '\0'};
struct REG_node node2 = {nullptr, '\0', nullptr, '\0'};
node1.first_neighbor = &node2;
struct REG_graph graph = {&node1, &node2};
return graph;
}
Aucun commentaire:
Enregistrer un commentaire