我需要帮助为多个.hpp和.cpp文件创建一个正确的makefile(支持增量编译).
我一直在寻找有关如何创建正确的makefile的信息,但我不确定如何做到这一点.
我有以下文件:2048.cpp,game.cpp,game.hpp,gameutils.cpp,gameutils.hpp,menu.cpp,menu.hpp,saveandback.cpp,saveandback.hpp和tile.hpp
现在我正在使用以下makefile:
all: 2048.cpp tile.hpp menu.hpp menu.cpp gameutils.hpp gameutils.cpp saveandback.hpp saveandback.cpp game.hpp game.cpp
g++ -g -W -Wall --pedantic -DNDEBUG 2048.cpp -o power
clean:
$(RM) power
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
我想使用迭代器打印一个向量:
#include <vector>
#include <istream>
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <math.h>
using namespace std;
typedef vector<int> board;
typedef vector<int> moves;
int sizeb;
board start;
moves nmoves;
istringstream stin;
board readIn(std :: istream& in ) {
int val;
while (in >> val)
start.push_back(val);
sizeb = start[0];
return start;
}
void printboard(board n) {
int sizem = sizeb*sizeb;
int i = 1;
for (vector<int>::iterator it = start.begin() ; it != start.end(); ++it) {
for (int j = 0; j < …Run Code Online (Sandbox Code Playgroud)