谈到GNU make,PHONY目标all:与之间的区别是什么default:.
CC=g++
default: hello
hello: hello.cpp
$(CC) -o hello hello.cpp
Run Code Online (Sandbox Code Playgroud)
和
CC=g++
all: hello
hello: hello.cpp
$(CC) -o hello hello.cpp
Run Code Online (Sandbox Code Playgroud)
他们俩都做同样的工作.
我定义了一个班级
class Rent
{
public:
int s_time, duration, price, e_time;
Rent(int s, int d, int p)
{
s_time = s;
duration = d;
price = p;
e_time = s + d;
}
bool operator<(Rent const &r1)
{
return e_time < r1.e_time;
}
};
Run Code Online (Sandbox Code Playgroud)
希望根据对其进行排序e_time,因此我已经定义<了Rent,但是,我不断收到错误消息
rent.cpp:38:12: error: no match for ‘operator+’ (operand types are ‘std::vector<Rent>’ and ‘int’)
sort(R, R+n);
^
Run Code Online (Sandbox Code Playgroud)
当我尝试的时候sort(R, R+n);。R是类型的向量,Rent并且n是整数(向量的大小)。
除上述以外,我尝试了这两种方法,但仍然失败!
sort(R, R + sizeof(R)/sizeof(R[0])); …Run Code Online (Sandbox Code Playgroud)