Results 1 to 5 of 5

Thread: Including .cpps

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80

    Including .cpps

    Is it possible to include .cpps? There are integer data types in my main.cpp I want to use in another .cpp, how would I do this?

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Yes, it's possible, but it's not good practice to include .cpp files. You should have it in a .h file instead. Just do:
    Code:
    #include "file.cpp"
    // Or
    #include "file.h"
    Alcohol & calculus don't mix.
    Never drink & derive.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    How do I put it in a .h file?

  4. #4
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    If you want to do an .h-file it's only to open a new file and write:

    Code:
    #ifndef _name_h_
    #define _name_h_
    #include <iostream>
    .....
    using namespace std;
    
    code.......
    .
    .
    .
    #endif
    save it later as an .h-file.

    If you want your variables to be global, then you have to declare them to be that, else they'll be local variables in your main.cpp-file.

    good luck!
    Last edited by [praetorian]; Dec 23rd, 2001 at 12:43 PM.
    [p r a e t o r i a n]

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    AAAHH

    NEVER include cpp or c files! NEVER NEVER NEVER!

    A header file is simply a file where type, variable and function declarations are. You include the header in every module (.c or .cpp file) where you need the types/functions/variables. NOT vice versa!
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width