1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Program With C++ style

Discussion in 'C++' started by sdmahapatra, Jul 16, 2009.

  1. sdmahapatra

    sdmahapatra New Member

    I've tried myself but failed as I never before use visual studio (VC++).So I need your suggestion to solved this problem.Which steps I need to follow?How do I separate the module in proper way?Which portion should I care more?etc....So please give your suggestion to know actual advantages of c++/vc++.


    With warm Regards
    sdmahapatra
     
  2. xpi0t0s

    xpi0t0s Mentor

    The point of header files is to share definitions between multiple source files. So if you only have one source file there's no point in having a header file.
     
  3. sdmahapatra

    sdmahapatra New Member

    Thanks for your suggestion, So xpi0t0s, If I don't have one source file then how to do this? header files,class,member functions(for process) and main(for application) should be in separate window and I want to execute the program properly.

    Thanks
     
  4. xpi0t0s

    xpi0t0s Mentor

    It doesn't necessarily follow that stuff that has to be in different windows has to be in different source files. Form design and software design are linked but do not necessarily have to follow each other. Anyway here is an example of a header file included by two source files (not tested):

    inc.h:
    Code:
    #define FOO 27
    int bar();
    
    main.c:
    Code:
    #include <stdio.h>
    #include "inc.h"
    
    int main()
    {
      printf("FOO=%d; bar()=%d\n",FOO,bar());
      return 0;
    }
    
    gronk.c:
    Code:
    #include <stdio.h>
    #include "inc.h"
    
    int bar()
    {
      printf("in bar(), returning %d\n",FOO);
      return FOO;
    }
    
    Compile with something like gcc main.c gronk.c -o main
    and this will compile main.c and gronk.c to produce main.o and gronk.o, then link them together.
    Output should be something like:

    in bar(), returning 27
    FOO=27; bar()=27
     
  5. sdmahapatra

    sdmahapatra New Member

    Hi xpi0t0s, yes I'll try it and if it'll going well then using this way I'll try to go more depth and then I let you know. thanks xpi0t0s for your concern about this problem.I think it will enough for me.thanks
     

Share This Page