C++ Programing with out header files
-
can we work with c++ with out any header file. like iostream etc. If posible give example
-
can we work with c++ with out any header file. like iostream etc. If posible give example
You can but it makes no sense in most cases. An example:
int main(int argc, char *argv[])
{
int res = 0;
for (int i = 1; i < argc; i++)
{
int j = 0;
while (argv[i][j])
res += argv[i][j++];
}
return res;
} -
can we work with c++ with out any header file. like iostream etc. If posible give example
Do you know why you have header files? If you do you will rralise you can of course write code without them.
-
can we work with c++ with out any header file. like iostream etc. If posible give example
As suggested above, yes you can. However, it's entirely pointless to do so! Include files help you organize your program in managable chunks, and let you use preexisting libraries, including all system functions. Likewise, if your program itself provides useful functions, you can put your function declarations into a header file so others can use it too. Which begs the question: why are you even asking?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
As suggested above, yes you can. However, it's entirely pointless to do so! Include files help you organize your program in managable chunks, and let you use preexisting libraries, including all system functions. Likewise, if your program itself provides useful functions, you can put your function declarations into a header file so others can use it too. Which begs the question: why are you even asking?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
Do you know why you have header files? If you do you will rralise you can of course write code without them.
I am student of bscs 1st semester. this question arise in my mind because when we working with header files thn we should memorize name of all header files and function related to these files . if we able to do programing with out using these files, I think its better to learn more and practice more.
-
I am student of bscs 1st semester. this question arise in my mind because when we working with header files thn we should memorize name of all header files and function related to these files . if we able to do programing with out using these files, I think its better to learn more and practice more.
-
I am student of bscs 1st semester. this question arise in my mind because when we working with header files thn we should memorize name of all header files and function related to these files . if we able to do programing with out using these files, I think its better to learn more and practice more.
Don't you think that if it would be easier without header files, that millions of coders before you hadn't found out about that a long time ago? The memorization isn't an issue: In C++ the usual way of organizing your code is that you use one header file for the declaration of each class, and one corresponding source file for the implementation of each class. You use the same base name for the header file and the source file, only the suffix is different! Moreover, you normally use an integrated development environment (IDE), which helps you organize your program, much like a file explorer. It will help you jump from a given variable or type or class in your code directly to the location in your code where it's defined. You really don't need to memorize anything! The application I work on has more than 3 million lines of code and consists of several thousand files - I don't even try to memorize where everything is! That is what the IDE does for me. And it works: If someone reports a bug I can usually locate the rough area of code where something goes awry within 10-20 minutes - even if I've never seen that code before!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
can we work with c++ with out any header file. like iostream etc. If posible give example