linker - Undefined reference to constructor and destructor c++ -


The error I am getting is:

  = === Build: Debug in Building Sim (compiler: GNU GCC compiler) === | Obj / debug / main.o || `__static_initialization_and_destruction_0 'in the function: | Reference to '/home/josh/Documents/cpp/building_sim/main.cpp | 15`` Reference: User: ~ User ()' | Regarding '/ user: user' References referred to in context of `home/josh/Documents/cpp/building_sim/main.cpp | 20`````` Building :: ~ Building () '| Regarding '/ user: user' || === Build Failed: 4 Error (), 0 Warning (0 Minutes, 0 Seconds (Seconds)) === |   

I have been facing this error for a few days and I have seen 14-18 sources who answer this issue which do nothing for me. At this point my project is made up of five files:

  main.cpp user.hpp user.cpp building.hpp building.cpp   

main. Cpp link building.hpp and user.hpp, create and link user.cpp with their respective header files and building.cpp links user.hpp.

I have tried to make this project several times in two different ways. I have all three CPP files O files to create a shell script and then to join them (in all possible orders), and I could just possibly try g ++ main.cpp building.cpp user.cpp And I created a code :: block project to manually link all the files. All of my headlines include guards, but I do not think this is an issue.

The full text of my files is as follows.

main.cpp

  # include & lt; Stdio.h & gt; #include "building.hpp" #include "user.hpp" // TODO text parsing // TODO resource / etc namespace generation using std; // ---------------------------------- // variable // --------- ------------------------- // ----- User ------ User User (1000); // --- Building --- Int Newbillings = 0; Building Building 1 (Users, 10, 14, "George"); Building building [] = {building1}; Int main () {Return 0; }   

user.hpp

  #include & lt; Stdio.h & gt; #ifndef user_h #define user_h class user {public: user (); ~ User (); User (int_money); Int getMoney (); Zero setmani (int main); Int getBuildings (); Zero set-building (int bldg); Private: Intimate Money; Int buildings; }; #endif   

user.cpp

  #include "user.hpp" user :: user () {user: money = 1000; User :: buildings = 0; } User: User (int _money) {User: money = _money; SetBuildings (getBuildings () + 1); } Int User :: getMoney () {user: money back; } Zero users: setMoney (int _money) {user: money = _money; } Int user :: getBuildings () {return user :: buildings; } Zero user :: SetBilling (int building) {user :: building = building; }   

building.hpp

  #include & lt; Iostream & gt; #include & lt; String & gt; #include "user.hpp" #ifndef building_h #define building_h Building Building {Public: Building (); ~ Building (); Building (user user); Building (user user, int _cost, int _payout); Building (user user, int _cost, int _payout, std :: string _name); Int getCost (); Int homepage (); Private: Int cost; Int payout; std :: string name; }; #endif   

building.cpp

  #include "building.hpp" building :: building () {std :: cout & lt; & Lt; "\ N [Error] Default constructor used, no building was built. \ N"; } Building :: Buildings (user users) {building :: cost = 10; Building :: Payout = 20; Building :: name = "generic"; User.setBuildings (user.getBuildings () +1); } Building :: Buildings (user user, int _cost, int_payout) {building :: cost = _cost; Building :: Payout = _payout; Building :: name = "generic"; User.setBuildings (user.getBuildings () +1); } Building :: Buildings (user user, int _cost, int _payout, std :: string _name) {building :: cost = _cost; Building :: Payout = _payout; Building :: name = _name; User.setBuildings (user.getBuildings () +1); } Int Building: Millcast () {Return Building :: Cost; } Int Building :: Outout () {Return Building :: Payout; }   

You just forgot to define both the killers: users and building CPP modules according to .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -