【发布时间】:2011-02-05 20:17:42
【问题描述】:
伙计们,我是一名初级程序员,需要帮助。我正在处理位于此处的作业的 A 部分:http://cs.binghamton.edu/~sgreene/cs240-2010f/labs/lab2.html
但是我在编译我的程序时遇到了问题。请告诉我在我的makefile 和cpp 文件中我做错了什么!这是我的文件:
# CS240 Lab2 Makefile
all: lab2
lab2: lab2.o
g++ -Wall lab2.o -o lab2
lab2.o: main.cpp
g++ -Wall -c main.cpp -o lab2.o
lab2.o: tenstrings.cpp
g++ -Wall -c tenstrings.cpp -o lab2.o
/*tenstrings.h*/
#ifndef TENSTRNGS
#define TENSTRNGS
class TenStrings
{
public:
// Default Constructor
TenStrings();
}
#endif
/* tenstrings.cpp */
#include "TenStrings.h"
//Default Constructor
TenStrings::TenStrings()
{}
/* main.cpp */
#include "TenStrings.h"
int main()
{
TenStrings varTen;
return 0;
}
正如你所看到的,这甚至不是一个程序,它只是为了让我开始编译,但我遇到了一堆错误:
________________________________________________________________________________________
Makefile:12: warning: overriding commands for target 'lab2.o'
Makefile:9: warning: ignoring old commands for target 'lab2.o'
g++ -Wall -c tenstrings.cpp -o lab2.o
In file included from tenstrings.cpp:6:
TenStrings.h:11:3: warning: no newline at end of file
tenstrings.cpp:7: error: new types may not be defined in a return type
tenstrings.cpp:7: error: return type specification for constructor invalid
_________________________________________________________________________________________
提前致谢!
【问题讨论】:
-
要使代码以固定宽度字体显示,缩进4个空格!看起来会好很多!
标签: c++ makefile compiler-errors