c++ 下传递字符串的两种方式

char* 传递

void OutputRecodingDataToCSV(char* info, int id);

void ThreadDataRecording::OutputRecodingDataToCSV(char* info, int id)
 {
    std::ofstream outFile;

    outFile.open("/home/moi/SlamKarto_ThreadData.csv", std::ios::app);

    outFile << time(NULL) - StartTime << ',' <<  info << ',' <<  id << std::endl;

    outFile.close();

    }


//实例化后使用
  char* hello = "Recording~!";
  Thread_RECORDING.OutputRecodingDataToCSV(hello, omp_get_thread_num());    

std ::string 传递

#include // 包含头文件

void OutputRecodingDataToCSV(std::string info, int id);

void ThreadDataRecording::OutputRecodingDataToCSV(std::string info, int id)
 {
    std::ofstream outFile;

    outFile.open("/home/moi/SlamKarto_ThreadData.csv", std::ios::app);

    outFile << time(NULL) - StartTime << ',' <<  info << ',' <<  id << std::endl;

    outFile.close();

    }


//实例化后使用
  Thread_RECORDING.OutputRecodingDataToCSV("coreNum", omp_get_thread_num());        

你可能感兴趣的:(C++)