member functions question

This is a discussion on member functions question within the C++ Programming forums, part of the General Programming Boards category; Why cant a member function that is declared as static also be declared as const? Code: class C { static ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    member functions question

    Why cant a member function that is declared as static also be declared as const?

    Code:
    class C {
        static void f() const;  // error
    };
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Might be this is the answer

    I believe that whenever you make a member function as const, that const actually is applied on the this pointer.

    Since static member functions don't have the this pointer, they can't co-exist.


    Note: I ain't sure.... just thinking
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers to member functions - quick Q
    By Stonehambey in forum C++ Programming
    Replies: 18
    Last Post: 09-01-2008, 11:30 AM
  2. Static functions.... why?
    By patricio2626 in forum C++ Programming
    Replies: 4
    Last Post: 04-02-2007, 08:06 PM
  3. member functions can't see private data members
    By ichijoji in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2006, 01:36 PM
  4. Templated member functions
    By Highland Laddie in forum C++ Programming
    Replies: 5
    Last Post: 05-15-2006, 05:25 PM
  5. help with classes and member functions
    By syner in forum C++ Programming
    Replies: 4
    Last Post: 07-19-2002, 08:45 PM

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