1. operator的用法
c++工程文件结构:
test.h具体:
#include<iostream>
using namespace std;
class V_3d{
public:
double x,y,z;
V_3d(double x_,double y_, double z_):x(x_),y(y_),z(z_)
{
cout<<x<<","<<y<<","<<z<<endl;
}
bool operator() (){
cout<<"你好啊,重载的()"<<endl;
if(x>0&&y>0&&z>0)
return 1;
else
return 0;
}
};
test.cpp具体:
#include"test.h"
using namespace std;
int main(int argc,char* argv[]){
cout<<"hello world, hello operator"<<endl;
V_3d p0={-10,0,0};
V_3d p1={0,0,0};
V_3d p2={2,3,4};
V_3d p3={3,5,7};
cout<<p1.x<<","<<p1.y<<","<<p1.z<<endl;
cout<<p3.x<<","<<p3.y<<","<<p3.z<<endl;
cout<<p0()<<endl;
cout<<p1()<<endl;
cout<<p3()<<endl;
return 0;
}
CMakeLists.txt 具体:
cmake_minimum_required(VERSION 3.10)
project(test)
include_directories(include)
add_executable(test test.cpp)
标签:int,double,namespace,笔记,Fusion,test,VINS,include
From: https://www.cnblogs.com/derek-dhb/p/17497123.html