Thread: Reference to a pointer to a pointer

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Turn up compiler warnings to level 4. I suspect you will get a warning, since this is a Microsoft extension (accepting a non-const reference to a temporary).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User Sharke's Avatar
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    303
    I can also do this with no warnings:

    Code:
    class X
    {
        int n;
    public:
        X() {}
        void set_n(int nn) {n = nn;}
    };
    
    X f1() {X x; return x;}
    
    void f2(X& x) {X& y = x; y.set_n(5);}
    
    int main() { f2(f1()); }

  3. #18
    Registered User Sharke's Avatar
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    303
    Quote Originally Posted by Elysia View Post
    Turn up compiler warnings to level 4. I suspect you will get a warning, since this is a Microsoft extension (accepting a non-const reference to a temporary).
    Is now my default!

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Warning 1 warning C4239: nonstandard extension used : 'argument' : conversion from 'X' to 'X &'
    This is what you should see with the highest warning level.
    If you select to disable language extensions, it will yield a compile error.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. Replies: 5
    Last Post: 04-04-2009, 03:45 AM
  3. Using Vectors. MinGW warning
    By Viewer in forum C++ Programming
    Replies: 9
    Last Post: 03-26-2009, 03:15 PM
  4. Strange/false errors
    By Ganoosh in forum Windows Programming
    Replies: 8
    Last Post: 10-20-2005, 04:54 PM
  5. C++ pointer vs reference
    By C-Dumbie in forum C++ Programming
    Replies: 4
    Last Post: 11-04-2002, 04:08 AM