Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ Programing with out header files

C++ Programing with out header files

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sadaf Rehman Najmi
    wrote on last edited by
    #1

    can we work with c++ with out any header file. like iostream etc. If posible give example

    J E S T 4 Replies Last reply
    0
    • S Sadaf Rehman Najmi

      can we work with c++ with out any header file. like iostream etc. If posible give example

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      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;
      }

      1 Reply Last reply
      0
      • S Sadaf Rehman Najmi

        can we work with c++ with out any header file. like iostream etc. If posible give example

        E Offline
        E Offline
        Erudite_Eric
        wrote on last edited by
        #3

        Do you know why you have header files? If you do you will rralise you can of course write code without them.

        S 1 Reply Last reply
        0
        • S Sadaf Rehman Najmi

          can we work with c++ with out any header file. like iostream etc. If posible give example

          S Offline
          S Offline
          Stefan_Lang
          wrote on last edited by
          #4

          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)

          L 1 Reply Last reply
          0
          • S Stefan_Lang

            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)

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Stefan_Lang wrote:

            why are you even asking?

            Probably an interview question.

            Veni, vidi, abiit domum

            1 Reply Last reply
            0
            • E Erudite_Eric

              Do you know why you have header files? If you do you will rralise you can of course write code without them.

              S Offline
              S Offline
              Sadaf Rehman Najmi
              wrote on last edited by
              #6

              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.

              C S 2 Replies Last reply
              0
              • S Sadaf Rehman Najmi

                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.

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                Sadaf Rehman Najmi wrote:

                because when we working with header files thn we should memorize name of all header files and function related to these files

                You trade such a little effort for a whole bunch of state-of-art functionality.

                Veni, vidi, vici.

                1 Reply Last reply
                0
                • S Sadaf Rehman Najmi

                  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.

                  S Offline
                  S Offline
                  Stefan_Lang
                  wrote on last edited by
                  #8

                  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)

                  1 Reply Last reply
                  0
                  • S Sadaf Rehman Najmi

                    can we work with c++ with out any header file. like iostream etc. If posible give example

                    T Offline
                    T Offline
                    tgsb
                    wrote on last edited by
                    #9

                    Yes you do this in C++ but its not a good approach we should always include header files in our programs. Its a good practice.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups