小编sin*_*ter的帖子

Makefile:所有vs默认目标

谈到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)

他们俩都做同样的工作.

makefile gnu-make

9
推荐指数
2
解决办法
1万
查看次数

在C ++中排序不匹配'operator +'

我定义了一个班级

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)

c++ sorting stl

2
推荐指数
1
解决办法
2442
查看次数

标签 统计

c++ ×1

gnu-make ×1

makefile ×1

sorting ×1

stl ×1