开发者

Error: ‘method’ was not declared in this scope

开发者 https://www.devze.com 2023-02-14 14:31 出处:网络
In my Method.h file: int method(); In my Method.cpp file: int metho开发者_高级运维d(){....} In my Main.cpp file:

In my Method.h file:

int method();

In my Method.cpp file:

int metho开发者_高级运维d(){....}

In my Main.cpp file:

method();

In my Makefile

EXEC = main
OBJS = Method.o
.PHONY: all
all: $(EXEC)

main: Main.cpp $(OBJS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
Method.o : Method.h Method.cpp

When i call make, it says that

Main.cpp: In function ‘int menu()’:
Main.cpp:26: error: ‘method’ was not declared in this scope
make: *** [main] Error 1

Can anybody tell me where I was wrong? Thank you!


Are you sure you include the method.h file in Main.cpp?


My first guess is to change the line

OBJS = Function.o

to

OBJS = Function.o Method.o

Also, Include Method.h in Main.cpp

// In Main.cpp
#include "Method.h"
0

精彩评论

暂无评论...
验证码 换一张
取 消