cmake内容如下:
cmake_minimum_required(VERSION 3.12)
project(testcmake1)
set(CMAKE_CXX_STANDARD 14)
add_executable(testcmake1 main.cpp test.cpp test.h)
test.h内容如下:
//
// Created by mushen on 18-12-24.
//
#ifndef TESTCMAKE1_TEST_H
#define TESTCMAKE1_TEST_H
#include <iostream>
class test {
public:
void plus() {};
};
#endif //TESTCMAKE1_TEST_H
test.cpp内容如下:
//
// Created by mushen on 18-12-24.
//
#include "test.h"
//这里提示redefination
void test::plus() {
std::cout << 1 << std::endl;
}
main.cpp内容如下:
#include <iostream>
#include "test.h"
int main() {
std::cout << "Hello, World!" << std::endl;
test t;
t.plus();
return 0;
}