如果我无法恢复此文件,我无法解释这将是多么令人沮丧.老实说,我觉得没有,但我需要了解到底发生了什么,所以我可以采取预防措施.从本质上讲,我正在制作一个简单的OOP项目,涉及EMACS中的虚假银行账户,并且在编译期间,.cpp文件包含所有类代码并且消失.
以下是消失文件之前和之后的终端命令:
lin114-11:25% ls
BankAccount.cpp BankAccount.h BankAccount.h~ main.cpp
lin114-11:26% emacs &
[1] 23359
lin114-11:27% g++ -o BankAccount.cpp main.cpp
/tmp/ccEXMM25.o: In function `main':
main.cpp:(.text+0x67): undefined reference to `CheckingAccount::driver()'
main.cpp:(.text+0x78): undefined reference to `CheckingAccount::~CheckingAccount()'
main.cpp:(.text+0xa1): undefined reference to `CheckingAccount::~CheckingAccount()'
main.cpp:(.text+0xcc): undefined reference to `CheckingAccount::~CheckingAccount()'
/tmp/ccEXMM25.o: In function `CheckingAccount::CheckingAccount(double, int,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
main.cpp:(.text._ZN15CheckingAccountC2EdiSs[_ZN15CheckingAccountC5EdiSs]+0x59):
undefined reference to `vtable for CheckingAccount'
collect2: ld returned 1 exit status
lin114-11:28% ls
BankAccount.h BankAccount.h~ main.cpp
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,BankAccount.cpp刚刚启动并在编译后消失.发生什么事了,无论如何要恢复文件?
jua*_*nza 17
当你这样做:
g++ -o BankAccount.cpp main.cpp
Run Code Online (Sandbox Code Playgroud)
你告诉g++编译main.cpp,并将输出写入一个名为的文件BankAccount.cpp.所以你用可执行文件覆盖你的源文件.