我正在实现集合层次结构,在这个项目中,我需要一些没有要实现的功能的抽象类,因此为这些类创建 .cpp 文件似乎是多余的。我有一个可以与 .cpp 文件一起正常工作的 Makefile,但在这种情况下出现了一些问题。
包含抽象类的文件(每个函数都是抽象的):
Run Code Online (Sandbox Code Playgroud)-collection.h -set.h -list.h -queue.h这些文件包含具体功能:
Run Code Online (Sandbox Code Playgroud)-hashSet.h -hashSet.cpp -arrayList.h -arrayList.cpp -linkedList.h -linkedList.cpp -iterator.h -iterator.cpp
我的 Makefile 如下
obj = main.o collection.o set.o list.o queue.o hashSet.o arrayList.o iterator.o
output : $(obj)
g++ -g -Wno-deprecated -std=c++11 -ansi -pedantic -Wall $(obj) -o output
main.o : main.cpp
g++ -g -Wno-deprecated -std=c++11 -c main.cpp
%.o : %.cpp %.h
g++ -g -Wno-deprecated -std=c++11 -c $<
clean :
rm *.o output
Run Code Online (Sandbox Code Playgroud)
当前错误:
make: *** No rule to make target 'collection.o', needed …Run Code Online (Sandbox Code Playgroud)