我的代碼有錯誤(錯誤C2512:'節點':沒有適當的默認構造函數可用) 但我有默認的構造函數爲什麼? 代碼評論我的錯誤位置,請幫我錯誤C2512,但我有默認的構造函數可用
Node.h
#pragma once
#include "stat.h"
#include "Automata.h"
#include <cstdlib>
class Node
{
friend class Automata;
friend class stat_a;
friend stat_a* makeauto(char *str);
friend int main();
private:
stat_a* mess;
char data;//harfi ke ba in masir estefadeh mishe :)
Node *next;//node badi dar araye node ha class stat_a :)
public:
Node()
{
mess = NULL;
next = NULL;
};
};
stat.h
#pragma once
#include "Node.h"
#include <iostream>
using namespace std;
class stat_a
{
friend class Automata;
friend class Node;
friend int main();
private:
bool is_final_stat_a; //aya final stat_a hast ???
int stat_a_num; //shomareh halat 0,1,2,...
Node *last; //akharin node dar araye node haye neshan dahande masir
Node *first; //Avalin node dar araye node haye neshan dahande masir
public:
void add(char d,stat_a * a)//ezafeh kardan masiri ke ba estefadeh
{ //az harf (char d) be halat (stat_a a) miravad
if(first == NULL)
{
first = new Node;//error is here
first->data = d;
first->mess = a;
last=first;
}
else
{
last->next = new Node ;//erorr is here
last=last->next;
last->data=d;
last->next=NULL;
last->mess=a;
}
};
/***********************************************************************/
void print()
{
cout<<stat_a_num<<"========> is final_stat_a : "<<is_final_stat_a<<endl;
Node *a;
a=first;
while(a != NULL)
{
cout<<"========> By '"<<a->data<<"' go to stat "<<a->mess->stat_a_num<<endl;
a=a->next;
}
};
stat_a()
{
last=NULL;
first=NULL;
is_final_stat_a=false;
};
~stat_a(void);
};
我有默認的構造函數可用,爲什麼出錯
您當地的語言下次就要求對計算器的幫助。請刪除註釋,它只是一個噪音的人誰不熟悉你的語言,分心真正的問題。 – SpongeBobFan
您有循環包含依賴項。這是行不通的。 – juanchopanza
不要像過去那樣過分地交朋友,只在真正需要時才保留它(在99.99%的情況下永遠不會)。 –