Thread: non-external declarations...

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

    Unhappy non-external declarations...


    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 - */
    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

    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
    Look up namespace and using namespace keywords. They handle what you like to do.

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

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, 12: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, 11:39 AM