Jump to content
  • Advertisement
Sign in to follow this  
ekrax

mmm multiple source files ..

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

well for the longest time ive been using .h files have the declaration and the defination and never really botherd with multiple source files ... but i guess thats stupid so now im trying to use multiple source files and i cant get anything to work, ive read a bunch of articles on this forum but it still isnt clear. here is an example ... Common.h _______________________________ #include <iostream> #include <string> #include <vector> typedef unsigned char byte; typedef unsigned int uint; extern Car; // ??? _______________________________ Car.h _______________________________ #include "Common.h" class Car { private: uint fuel; uint oil; public: void fillFuel(uint); void fillOil(uint); uint condition(); Car(); }; _______________________________ Main.cpp _______________________________ #include "Common.h" int main() { Car honda(); return 0; } _______________________________ Car.cpp _______________________________ #include "Common.h" #include "Car.h" void Car::fillFuel(uint x) { fuel += x; if (fuel > 100) fuel = 100; } void Car::fillOil(uint x) { oil += x; if (oil > 100) oil = 100; } uint Car::condition() { return (fuel + oil) / 2; } Car::Car() { fuel = 100; oil = 100; damage = 0; } _______________________________ this is what im trying just to try and get the multiple source files working but it doesnt work ... so my question(s) is why doesnt this work? how do i use a common header and get around recompiling compiled code? should using multiple source files follow this format: common.h main.cpp main.h other.cpp other.h things.cpp things.h ... where every .h file contains common.h ??? im lost on this. thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!