disambiguation

This is a discussion on disambiguation within the C++ Programming forums, part of the General Programming Boards category; If I want to use a method with the same name as a standard function (stat), how can I disambiguate ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    disambiguation

    If I want to use a method with the same name as a standard function (stat), how can I disambiguate this inside the class definition, eg:

    Code:

    if (stat(fpath,&(cur.st)) == EACCES) {

    This is a normal stat call, but within a class method definition it appears to be a call to the method of the same name. I tried "std::stat" but that don't work...
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,781
    stat is not part of the standard library, so you probably should use ::stat, i.e., qualify it as being from the global namespace.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Thanks!
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. name binding from one template to another
    By George2 in forum C++ Programming
    Replies: 18
    Last Post: 03-14-2008, 08:15 AM

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