Note that there are some explanatory texts on larger screens.

plurals
  1. POunresolved externals Error in C++ Project
    primarykey
    data
    text
    <p>I wrote my project using a simple editor and I compile them by using Microsoft vc++ compiler through command line interface, I am getting the following error:</p> <pre><code>/out:Main.exe Main.obj </code></pre> <blockquote> <p>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Ac count::debit(int)" (?debit@Account@@QAEXH@Z) referenced in function _main</p> <p>Main.obj : error LNK2019: unresolved external symbol "public: int __thiscall Acc ount::getBalance(void)" (?getBalance@Account@@QAEHXZ) referenced in function _main</p> <p>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall Account ::Account(int)" (??0Account@@QAE@H@Z) referenced in function _main Main.exe : fatal error LNK1120: 3 unresolved externals</p> </blockquote> <p>Here is the code:</p> <pre><code>//File : Account.h class Account{ public: Account( int ); void credit( int ); void debit( int ); int getBalance(); private: int balance; }; </code></pre> <pre><code>//File:Account.cpp #include&lt;iostream&gt; using std::cout; using std::endl; #include "Account.h" Account::Account( int initialbalance ){ balance = 0; if( initialbalance &gt; 0 ) balance = initialbalance; if ( initialbalance &lt; 0 ) cout&lt;&lt;"Initial Balance is empty\n"&lt;&lt;endl; } void Account::credit( int amount ){ balance = balance + amount; } void Account::debit( int amount ){ if( amount &lt;= balance ) balance = balance - amount; else cout&lt;&lt;"Debit amount exceed balance amount\n"&lt;&lt;endl; } int Account::getBalance(){ return balance; } </code></pre> <pre><code>//File : Main.cpp #include&lt;iostream&gt; using std::cout; using std::endl; using std::cin; #include "Account.h" int main(){ Account obj(50); cout&lt;&lt;"Account balance Rs. "&lt;&lt;obj.getBalance()&lt;&lt;"\n"&lt;&lt;endl; int withdraw; cout&lt;&lt;"Withdrawal amount for your account\n"&lt;&lt;endl; cin&gt;&gt;withdraw; cout&lt;&lt;"Withdrawing ....."&lt;&lt;endl; obj.debit( withdraw ); cout&lt;&lt;"Final account balance : "&lt;&lt;obj.getBalance()&lt;&lt;endl; return 0; } </code></pre> <p>I have first compiled Account.cpp by using "cl /LD Account.cpp" , then when i try to compile "Main.cpp" I get these error , to be specific I want to know how to use a compiled .dll or .obj file in my client code that uses these compiled files when their source code is not available .</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload