non-external declarations...

This is a discussion on non-external declarations... within the C++ Programming forums, part of the General Programming Boards category; hi, I have an application with 2 .cpp files. I want to be able to have identical Function names in ...

  1. #1
    Registered User headexplodes's Avatar
    Join Date
    Aug 2001
    Posts
    26

    Unhappy non-external declarations...

    hi,

    I have an application with 2 .cpp files. I want to be able to have identical Function names in each file (a function called myfunc() in both).

    Also I want to be able to make my variables to be visible from only in .cpp file that they were declared in.

    is the auto specifier supposed to do this? when i tried putting that on my variables it said it was invalid.

    any help would be great.
    /* MSN and E-Mail - head_explodeshotmail.com */
    If Bill Gates got a dollar for every time windows crahsed... oh... he does.
    I always use MSVC++6.0

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    142
    hiya,

    am not sure if it's possible to have two exactly similar function name in a single project because by default, functions are declared extern...,

    but with varaibles, they aren't, if you want to use the global variable across multiple cpps, then you should declare it extern so maybe, you can use a exactly the same global variable here and another global variable there


  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    Look up namespace and using namespace keywords. They handle what you like to do.

    small example:
    Code:
    namspace apa{
        int A(){
         ...
        }
    }
    
    namespace bepa{
        int A(){
         ...
        }
    }
    
    ---------
    apa::A();
    bepa::A();
    
    ---------
    using namespace apa;
    A(); // apa::A()
    apa::A(); //still works
    bepa::A();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM
  5. Ask about these "unresolved external symbol" error
    By ooosawaddee3 in forum C++ Programming
    Replies: 1
    Last Post: 06-29-2002, 12:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21