C++ 未定义的引用ld返回1退出状态

C++ 未定义的引用ld返回1退出状态,c++,C++,我创建了一个头文件(account.h)、一个方法定义文件(account.cpp)和一个主文件(ex2.cpp) 当我编译主文件时,我得到一个错误“未定义的引用” 详细错误是:-/tmp/ccps76QE.o:在函数'main'中: ex2.cpp:(.text+0x8d):对“Account::init(std:_cxx11::basic_string const&,unsigned long,double)”的未定义引用 ex2.cpp:(.text+0xb7):对“Account::di

我创建了一个头文件(account.h)、一个方法定义文件(account.cpp)和一个主文件(ex2.cpp)

当我编译主文件时,我得到一个错误“未定义的引用”

详细错误是:-/tmp/ccps76QE.o:在函数'main'中:
ex2.cpp:(.text+0x8d):对“Account::init(std:_cxx11::basic_string const&,unsigned long,double)”的未定义引用
ex2.cpp:(.text+0xb7):对“Account::display()”的未定义引用
ex2.cpp:(.text+0xd6):对“Account::display()”的未定义引用
ex2.cpp:(.text+0x134):对“Account::init(std:_cxx11::basic_string const&,unsigned long,double)”的未定义引用
ex2.cpp:(.text+0x15e):对“Account::display()”的未定义引用
ex2.cpp:(.text+0x178):对“Account::display()”的未定义引用


请帮助我解决这个问题,因为我是编程和c++新手

您必须编译ex2.cpp和account.cpp以及link,目前您只编译ex2.cpp非常感谢您的回复。你能告诉我怎么做吗?@RajRajeshwariPrasad例如
g++account.cpp ex2.cpp
只要列出编译器调用的所有
.cpp
。非常感谢你的帮助。它工作正常。我被困在这里面好几个小时了。
The detailed error is:-/tmp/ccps76QE.o: In function `main':
ex2.cpp:(.text+0x8d): undefined reference to `Account::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, double)'
ex2.cpp:(.text+0xb7): undefined reference to `Account::display()'
ex2.cpp:(.text+0xd6): undefined reference to `Account::display()'
ex2.cpp:(.text+0x134): undefined reference to `Account::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, double)'
ex2.cpp:(.text+0x15e): undefined reference to `Account::display()'
ex2.cpp:(.text+0x178): undefined reference to `Account::display()'