【发布时间】:2018-09-18 07:51:10
【问题描述】:
我创建了一个头文件ll.h,其中包含 2 个类。代码是这样的:
#pragma once
#include<iostream>
#include<conio.h>
using namespace std;
class N{
public:
int data;
N *next;
public:
N(int);
~N();
};
class ll{
public:
N *head;
public:
ll();
~ll();
void aFr(N*);
void aEn(N*);
};
N::N (int d){
data = d;
next = NULL;
}
N::~N{}
ll::ll(){
head = NULL;
}
ll::~ll(){}
void aFr(N* n){
n->next = head; //identifier "head" undefined
head = n;
}
void aEn(N* n){
if (head == NULL)// identifier "head" undefined
{
head = n;
n->next = NULL;
}
}
这两个函数中的head 似乎不应该调用任何错误。
我还是个初学者,如果是小事请见谅。
我知道这应该不是问题,但我为类和声明本身使用了不同的窗口。
我正在使用 Visual Studio 2010 运行代码。
【问题讨论】:
-
注意:您应该将函数定义放在源文件 (
.cpp) 中,并在该源文件中包含带有#include "ll.h"的标头。
标签: c++ compiler-errors undeclared-identifier