0
我希望能夠以char *形式將常量字符串附加到另一個字符串的末尾,然後將結果字符串用作open()的參數。這裏是什麼樣子:結合靜態char *和常量字符串
file1.cpp
#include "string.h"
file2 foo;
char* word = "some";
foo.firstWord = word; //I want the file2 class to be able to see "some"
file2.h
#include <fstream>
#include <iostream>
#define SECONDWORD "file.txt"
class file2{
public:
file2();
static char* firstWord;
static char* fullWord;
private:
ofstream stream;
}
file2.cpp
#include "file2.h"
char* file2::firstWord;
char* file2::fullWord;
fullWord = firstWord + SECONDWORD; //so fullWord is now "somefile.txt" ,I know this doesn't work, but basically I am trying to figure out this part
file2::file2(){
stream.open(fullWord);
}
所以我不是在C十分精通++,所以任何幫助將不勝感激!