Using multiple files while coding in c++

I am working on wt (a web toolkit for c++). I remember hearing about it few years ago when i was in diploma and then I had an aquintance with it again as a challenge. The challenge was to build a website in wt. While i am working on the tutorials for wt, i am also working on creating a tutorial website for wt. (that was the challenge). So till now i (and many other novice programmers like me) have been happy with single .cpp file to put all the code in. No doubt we were very much told about the demerits and suggested a lot about having a good habit of having multiple files. I remember Indermohan Singh using header files in c++ few years back. But I was ignorant and never paid heed to it until i got struck into a place where there seems no other option.

Keeping all the code in single place is hell lot of problem and there is utter need to manage it and use it with multiple files. This has been lot easier with java, but as witty is wt and it's a c++ webtoolkit i have to choose c++. N
ow i don't know about handling stuff with multiple files. So i just ran a google search, it's 1927 hrs and I recently made a google query about design patterns in c++, while I am acquainted with design patterns in actionscript and they were pretty well transferable to java but c++ seems little different. You would think why to make a query for design pattern when you need information about using multiple files. There's a story behind it. In short it is that i never bothered to use multiple files in actionscript before i learnt (a very small bit of) design patterns and after that using multiple files was just normal. But again i failed here, due to lack of time I dropped the idea of looking for design patterns and started with direct search for using multiple files in c++ and it's 1952hrs.
It's 2010hrs and i have got the answer. I am using include "filename.cpp" simply and will later go with includ "filename.h". Header files are simple, in a line they are files with just declarations of the file that they belong to, thus allowing you to use them in other files and call functions, or make objects of the class related to that c plus plus file without "not declared in this scope error".

No comments:

Post a Comment