static member functions access to class members and methods

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roger Leigh

    static member functions access to class members and methods

    The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
    for Linux in 21 Days--I know there are better) states that "static
    member functions cannot access any non-static member variables".
    However, this doesn't seem entirely correct. It also doesn't mention
    whether static member functions can access protected and private
    member data and methods (and I couldn't spot this in the FAQ).

    I have a class row<Row> which derives from row_base:

    template<typena me Row>
    class row : public row_base
    {
    public:
    typedef std::auto_ptr<R ow> row_ptr;

    row(): row_base() {}

    row(row_state status, bool modified=false) :
    row_base(status , modified) {}

    virtual ~row() {}

    static row_ptr create(pqxx::re sult::const_ite rator row,
    pqxxobject::tra nsaction& tran)
    {
    row_ptr p(new Row);
    p->convert_impl(r ow, tran); // protected
    p->row_base::m_st ate = STATE_INITIALIS ED; // private
    return p;
    }

    virtual void convert_impl(pq xx::result::con st_iterator row,
    pqxxobject::tra nsaction& tran) = 0;

    }; // class row

    Here, in the static create() method, row_base::m_sta te is a private
    (enum) data member of the base class, yet I can assign it directly.
    However, convert_impl() is a pure virtual function which is public
    here and protected in the deriving class, but I get an error when I
    compile:

    places.cc: In static member function `static std::auto_ptr<_ Tp1>
    pqxxobject::row <Row>::create(p qxx::result::co nst_iterator,
    pqxxobject::tra nsaction&) [with Row = Place]':
    .../pqxx-object/table.h:172: instantiated from `std::auto_ptr< std::list<Row, std::allocator< _CharT> > > pqxxobject::tab le<Row>::find_m any(const std::string&) [with Row = Place]'
    places.cc:207: instantiated from here
    places.cc:175: error: `virtual void
    Place::convert_ impl(pqxx::resu lt::const_itera tor, pqxxobject::tra nsaction&)'
    is protected
    .../pqxx-object/row.h:97: error: within this context

    row.h:97 is the "p->convert_impl(r ow, tran);" line, above.

    I can't see the rationale between being able to access private data
    members, but not protected methods (which are actually public in the
    row<> class)!


    I would probably be better making create() call a specialised
    protected constructor, but I'm interested in learning why the above
    doesn't work.


    Thanks,
    Roger

    --
    Roger Leigh

    Printing on GNU/Linux? http://gimp-print.sourceforge.net/
    GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  • Rolf Magnus

    #2
    Re: static member functions access to class members and methods

    Roger Leigh wrote:
    [color=blue]
    > The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
    > for Linux in 21 Days--I know there are better) states that "static
    > member functions cannot access any non-static member variables".
    > However, this doesn't seem entirely correct.[/color]

    You're right. If your static member function has an object of the class,
    it can access member variables of that object.
    [color=blue]
    > It also doesn't mention whether static member functions can access
    > protected and private member data and methods (and I couldn't spot
    > this in the FAQ).[/color]

    It doesn't matter if the member is static or not. Any member function
    can access any protected and private member of the same class.
    [color=blue]
    > I have a class row<Row> which derives from row_base:
    >
    > template<typena me Row>
    > class row : public row_base
    > {
    > public:
    > typedef std::auto_ptr<R ow> row_ptr;
    >
    > row(): row_base() {}
    >
    > row(row_state status, bool modified=false) :
    > row_base(status , modified) {}
    >
    > virtual ~row() {}
    >
    > static row_ptr create(pqxx::re sult::const_ite rator row,
    > pqxxobject::tra nsaction& tran)
    > {
    > row_ptr p(new Row);
    > p->convert_impl(r ow, tran); // protected
    > p->row_base::m_st ate = STATE_INITIALIS ED; // private
    > return p;
    > }
    >
    > virtual void convert_impl(pq xx::result::con st_iterator row,
    > pqxxobject::tra nsaction& tran) = 0;
    >
    > }; // class row
    >
    > Here, in the static create() method, row_base::m_sta te is a private
    > (enum) data member of the base class, yet I can assign it directly.
    > However, convert_impl() is a pure virtual function which is public
    > here and protected in the deriving class, but I get an error when I
    > compile:
    >
    > places.cc: In static member function `static std::auto_ptr<_ Tp1>
    > pqxxobject::row <Row>::create(p qxx::result::co nst_iterator,
    > pqxxobject::tra nsaction&) [with Row = Place]':
    > ../pqxx-object/table.h:172: instantiated from
    > `std::auto_ptr< std::list<Row, std::allocator< _CharT> > >
    > pqxxobject::tab le<Row>::find_m any(const std::string&) [with Row =
    > Place]'
    > places.cc:207: instantiated from here
    > places.cc:175: error: `virtual void
    > Place::convert_ impl(pqxx::resu lt::const_itera tor,
    > pqxxobject::tra nsaction&)' is protected
    > ../pqxx-object/row.h:97: error: within this context
    >
    > row.h:97 is the "p->convert_impl(r ow, tran);" line, above.
    >
    > I can't see the rationale between being able to access private data
    > members, but not protected methods (which are actually public in the
    > row<> class)![/color]

    They are public in the row<> class, but you are declaring your pointer
    as row_ptr, which in your case is an auto_ptr<Place> . So you're
    accessing the object through a pointer to Place, where, as you say, the
    member is protected, i.e. only Place itself and classes derived from
    that can access it.

    Comment

    • Martijn Lievaart

      #3
      Re: static member functions access to class members and methods

      On Tue, 20 Jan 2004 12:48:55 +0100, Rolf Magnus wrote:
      [color=blue]
      > Roger Leigh wrote:
      >[color=green]
      >> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
      >> for Linux in 21 Days--I know there are better) states that "static
      >> member functions cannot access any non-static member variables".
      >> However, this doesn't seem entirely correct.[/color]
      >
      > You're right. If your static member function has an object of the class,
      > it can access member variables of that object.[/color]

      I guess it's a clumsy way of saying you have no this-pointer.

      M4

      Comment

      • Rolf Magnus

        #4
        Re: static member functions access to class members and methods

        Martijn Lievaart wrote:
        [color=blue]
        > On Tue, 20 Jan 2004 12:48:55 +0100, Rolf Magnus wrote:
        >[color=green]
        >> Roger Leigh wrote:
        >>[color=darkred]
        >>> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
        >>> for Linux in 21 Days--I know there are better) states that "static
        >>> member functions cannot access any non-static member variables".
        >>> However, this doesn't seem entirely correct.[/color]
        >>
        >> You're right. If your static member function has an object of the
        >> class, it can access member variables of that object.[/color]
        >
        > I guess it's a clumsy way of saying you have no this-pointer.[/color]

        It's not clumsy, it's just more explicit. Anyway, saying that static
        members cannot access non-static members is just plain wrong.

        Comment

        • Martijn Lievaart

          #5
          Re: static member functions access to class members and methods

          On Tue, 20 Jan 2004 19:14:13 +0100, Rolf Magnus wrote:
          [color=blue]
          > Martijn Lievaart wrote:
          >[color=green]
          >> On Tue, 20 Jan 2004 12:48:55 +0100, Rolf Magnus wrote:
          >>[color=darkred]
          >>> Roger Leigh wrote:
          >>>
          >>>> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
          >>>> for Linux in 21 Days--I know there are better) states that "static
          >>>> member functions cannot access any non-static member variables".
          >>>> However, this doesn't seem entirely correct.
          >>>
          >>> You're right. If your static member function has an object of the
          >>> class, it can access member variables of that object.[/color]
          >>
          >> I guess it's a clumsy way of saying you have no this-pointer.[/color]
          >
          > It's not clumsy, it's just more explicit. Anyway, saying that static
          > members cannot access non-static members is just plain wrong.[/color]

          My bad, I was referring to the original statement, not your explanation. I
          should have made that clearer.

          M4

          Comment

          • c++novice

            #6
            Re: static member functions access to class members and methods

            Roger Leigh <${roger}@inval id.whinlatter.u klinux.net.inva lid> wrote in message news:<87oesz3pp r.fsf@wrynose.w hinlatter.uklin ux.net>...[color=blue]
            > The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
            > for Linux in 21 Days--I know there are better) states that "static
            > member functions cannot access any non-static member variables".[/color]

            The static functions can address only the static data of a class;
            non-static data are unavailable to these functions. If non-static data
            could be addressed, to which object would they belong? Any attempt
            to access a normal class member will generate a compile time
            error. Similarly, static functions cannot call non-static functions of
            the class. All this is caused by the fact that static functions have
            no this pointer.


            [color=blue]
            > However, this doesn't seem entirely correct. It also doesn't mention
            > whether static member functions can access protected and private
            > member data and methods (and I couldn't spot this in the FAQ).
            >
            > I have a class row<Row> which derives from row_base:
            >
            > template<typena me Row>
            > class row : public row_base
            > {
            > public:
            > typedef std::auto_ptr<R ow> row_ptr;
            >
            > row(): row_base() {}
            >
            > row(row_state status, bool modified=false) :
            > row_base(status , modified) {}
            >
            > virtual ~row() {}
            >
            > static row_ptr create(pqxx::re sult::const_ite rator row,
            > pqxxobject::tra nsaction& tran)
            > {
            > row_ptr p(new Row);
            > p->convert_impl(r ow, tran); // protected
            > p->row_base::m_st ate = STATE_INITIALIS ED; // private
            > return p;
            > }
            >
            > virtual void convert_impl(pq xx::result::con st_iterator row,
            > pqxxobject::tra nsaction& tran) = 0;
            >
            > }; // class row
            >
            > Here, in the static create() method, row_base::m_sta te is a private
            > (enum) data member of the base class, yet I can assign it directly.
            > However, convert_impl() is a pure virtual function which is public
            > here and protected in the deriving class, but I get an error when I
            > compile:
            >
            > places.cc: In static member function `static std::auto_ptr<_ Tp1>
            > pqxxobject::row <Row>::create(p qxx::result::co nst_iterator,
            > pqxxobject::tra nsaction&) [with Row = Place]':
            > ../pqxx-object/table.h:172: instantiated from `std::auto_ptr< std::list<Row, std::allocator< _CharT> > > pqxxobject::tab le<Row>::find_m any(const std::string&) [with Row = Place]'
            > places.cc:207: instantiated from here
            > places.cc:175: error: `virtual void
            > Place::convert_ impl(pqxx::resu lt::const_itera tor, pqxxobject::tra nsaction&)'
            > is protected
            > ../pqxx-object/row.h:97: error: within this context
            >
            > row.h:97 is the "p->convert_impl(r ow, tran);" line, above.
            >
            > I can't see the rationale between being able to access private data
            > members, but not protected methods (which are actually public in the
            > row<> class)!
            >
            >
            > I would probably be better making create() call a specialised
            > protected constructor, but I'm interested in learning why the above
            > doesn't work.
            >
            >
            > Thanks,
            > Roger
            >
            > --
            > Roger Leigh
            >
            > Printing on GNU/Linux? http://gimp-print.sourceforge.net/
            > GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
            >
            >
            > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
            > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
            > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color]

            Comment

            • Nick Hounsome

              #7
              Re: static member functions access to class members and methods


              "c++novice" <belthezarcus20 04@yahoo.com> wrote in message
              news:3471bdd3.0 401201220.2c933 de4@posting.goo gle.com...[color=blue]
              > Roger Leigh <${roger}@inval id.whinlatter.u klinux.net.inva lid> wrote in[/color]
              message news:<87oesz3pp r.fsf@wrynose.w hinlatter.uklin ux.net>...[color=blue][color=green]
              > > The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
              > > for Linux in 21 Days--I know there are better) states that "static
              > > member functions cannot access any non-static member variables".[/color]
              >
              > The static functions can address only the static data of a class;
              > non-static data are unavailable to these functions. If non-static data
              > could be addressed, to which object would they belong? Any attempt
              > to access a normal class member will generate a compile time
              > error. Similarly, static functions cannot call non-static functions of
              > the class. All this is caused by the fact that static functions have
              > no this pointer.
              >[/color]

              No they can access any data and methods of the class - they just don't have
              a 'this'.
              [color=blue]
              >
              >[color=green]
              > > However, this doesn't seem entirely correct. It also doesn't mention
              > > whether static member functions can access protected and private
              > > member data and methods (and I couldn't spot this in the FAQ).
              > >
              > > I have a class row<Row> which derives from row_base:
              > >
              > > template<typena me Row>
              > > class row : public row_base
              > > {
              > > public:
              > > typedef std::auto_ptr<R ow> row_ptr;
              > >
              > > row(): row_base() {}
              > >
              > > row(row_state status, bool modified=false) :
              > > row_base(status , modified) {}
              > >
              > > virtual ~row() {}
              > >
              > > static row_ptr create(pqxx::re sult::const_ite rator row,
              > > pqxxobject::tra nsaction& tran)
              > > {
              > > row_ptr p(new Row);
              > > p->convert_impl(r ow, tran); // protected
              > > p->row_base::m_st ate = STATE_INITIALIS ED; // private
              > > return p;
              > > }
              > >
              > > virtual void convert_impl(pq xx::result::con st_iterator row,
              > > pqxxobject::tra nsaction& tran) = 0;
              > >
              > > }; // class row
              > >
              > > Here, in the static create() method, row_base::m_sta te is a private
              > > (enum) data member of the base class, yet I can assign it directly.
              > > However, convert_impl() is a pure virtual function which is public
              > > here and protected in the deriving class, but I get an error when I
              > > compile:
              > >
              > > places.cc: In static member function `static std::auto_ptr<_ Tp1>
              > > pqxxobject::row <Row>::create(p qxx::result::co nst_iterator,
              > > pqxxobject::tra nsaction&) [with Row = Place]':
              > > ../pqxx-object/table.h:172: instantiated from[/color][/color]
              `std::auto_ptr< std::list<Row, std::allocator< _CharT> > >
              pqxxobject::tab le<Row>::find_m any(const std::string&) [with Row = Place]'[color=blue][color=green]
              > > places.cc:207: instantiated from here
              > > places.cc:175: error: `virtual void
              > > Place::convert_ impl(pqxx::resu lt::const_itera tor,[/color][/color]
              pqxxobject::tra nsaction&)'[color=blue][color=green]
              > > is protected
              > > ../pqxx-object/row.h:97: error: within this context
              > >
              > > row.h:97 is the "p->convert_impl(r ow, tran);" line, above.[/color][/color]

              Are you certain because it seems to me that you shouldn't even be able to
              create a row since you have
              declared convert_impl pure virtual.
              [color=blue][color=green]
              > >
              > > I can't see the rationale between being able to access private data
              > > members, but not protected methods (which are actually public in the
              > > row<> class)!
              > >
              > >
              > > I would probably be better making create() call a specialised
              > > protected constructor, but I'm interested in learning why the above
              > > doesn't work.
              > >
              > >
              > > Thanks,
              > > Roger
              > >
              > > --
              > > Roger Leigh
              > >
              > > Printing on GNU/Linux?[/color][/color]
              http://gimp-print.sourceforge.net/[color=blue][color=green]
              > > GPG Public Key: 0x25BFB848. Please sign and encrypt[/color][/color]
              your mail.[color=blue][color=green]
              > >
              > >
              > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
              > > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
              > > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color][/color]


              Comment

              • Rolf Magnus

                #8
                Re: static member functions access to class members and methods

                c++novice wrote:
                [color=blue]
                > Roger Leigh <${roger}@inval id.whinlatter.u klinux.net.inva lid> wrote in
                > message news:<87oesz3pp r.fsf@wrynose.w hinlatter.uklin ux.net>...[color=green]
                >> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
                >> for Linux in 21 Days--I know there are better) states that "static
                >> member functions cannot access any non-static member variables".[/color]
                >
                > The static functions can address only the static data of a class;
                > non-static data are unavailable to these functions. If non-static data
                > could be addressed, to which object would they belong?[/color]

                Any object that is available to the function.
                [color=blue]
                > Any attempt
                > to access a normal class member will generate a compile time
                > error. Similarly, static functions cannot call non-static functions of
                > the class.[/color]

                Just like a non-member-function can access non-static data of a class, a
                static member function can. If you're still not convinced, explain
                this:

                #include <iostream>

                class X
                {
                public:
                static void foo(const X& x)
                {
                std::cout << x.text;
                }

                const char* text;
                };

                int main()
                {
                X x;
                x.text = "Hello world!\n";
                X::foo(x);
                }

                X::text is a non-static member of X, and still the static member
                function does access it.
                [color=blue]
                > All this is caused by the fact that static functions have
                > no this pointer.[/color]

                Right, they have no this pointer, but they can still access non-static
                members of the class if they get an instance of that class. They just
                are not called for a specific instance.

                Comment

                • c++novice

                  #9
                  Re: static member functions access to class members and methods

                  Rolf Magnus <ramagnus@t-online.de> wrote in message news:<buk9ms$m4 e$05$1@news.t-online.com>...[color=blue]
                  > c++novice wrote:
                  >[color=green]
                  > > Roger Leigh <${roger}@inval id.whinlatter.u klinux.net.inva lid> wrote in
                  > > message news:<87oesz3pp r.fsf@wrynose.w hinlatter.uklin ux.net>...[color=darkred]
                  > >> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
                  > >> for Linux in 21 Days--I know there are better) states that "static
                  > >> member functions cannot access any non-static member variables".[/color]
                  > >
                  > > The static functions can address only the static data of a class;
                  > > non-static data are unavailable to these functions. If non-static data
                  > > could be addressed, to which object would they belong?[/color]
                  >
                  > Any object that is available to the function.
                  >[color=green]
                  > > Any attempt
                  > > to access a normal class member will generate a compile time
                  > > error. Similarly, static functions cannot call non-static functions of
                  > > the class.[/color]
                  >
                  > Just like a non-member-function can access non-static data of a class, a
                  > static member function can. If you're still not convinced, explain
                  > this:
                  >
                  > #include <iostream>
                  >
                  > class X
                  > {
                  > public:
                  > static void foo(const X& x)
                  > {
                  > std::cout << x.text;
                  > }
                  >
                  > const char* text;
                  > };
                  >
                  > int main()
                  > {
                  > X x;
                  > x.text = "Hello world!\n";
                  > X::foo(x);
                  > }
                  >
                  > X::text is a non-static member of X, and still the static member
                  > function does access it.[/color]

                  U r very much right because here an object of type X is passed in
                  static member function foo()as a parameter,
                  But foo() is not directly accessing the member like
                  std::cout << text;

                  [color=blue]
                  >[color=green]
                  > > All this is caused by the fact that static functions have
                  > > no this pointer.[/color]
                  >
                  > Right, they have no this pointer, but they can still access non-static
                  > members of the class if they get an instance of that class. They just
                  > are not called for a specific instance.[/color]

                  Comment

                  • Roger Leigh

                    #10
                    Re: static member functions access to class members and methods

                    Rolf Magnus <ramagnus@t-online.de> writes:
                    [color=blue]
                    > Martijn Lievaart wrote:
                    >[color=green]
                    >> On Tue, 20 Jan 2004 12:48:55 +0100, Rolf Magnus wrote:
                    >>[color=darkred]
                    >>> Roger Leigh wrote:>
                    >>>
                    >>>> The C++ book I have to hand (Liberty and Horvath, Teach yourself C++
                    >>>> for Linux in 21 Days--I know there are better) states that "static
                    >>>> member functions cannot access any non-static member variables".
                    >>>> However, this doesn't seem entirely correct.
                    >>>
                    >>> You're right. If your static member function has an object of the
                    >>> class, it can access member variables of that object.[/color]
                    >>
                    >> I guess it's a clumsy way of saying you have no this-pointer.[/color]
                    >
                    > It's not clumsy, it's just more explicit. Anyway, saying that static
                    > members cannot access non-static members is just plain wrong.[/color]

                    Much of the book is like that. I found it fairly readable for the
                    basics of the language, but it leaves a lot of questions unanswered,
                    and the devil is always in the details.

                    I did get a copy of Stroustrup's TCPL from the library at the same
                    time, but as a C programmer with no OO knowledge, I was out of my
                    depth several pages into the introduction!! It would probably be OK
                    now I have a decent grasp of the language, but the 21 days books was
                    far more understandable at the time.


                    --
                    Roger Leigh

                    Printing on GNU/Linux? http://gimp-print.sourceforge.net/
                    GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.


                    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                    Comment

                    • Roger Leigh

                      #11
                      Re: static member functions access to class members and methods

                      Rolf Magnus <ramagnus@t-online.de> writes:
                      [color=blue]
                      > Roger Leigh wrote:
                      >[color=green]
                      >> I have a class row<Row> which derives from row_base:
                      >>
                      >> template<typena me Row>
                      >> class row : public row_base
                      >> {
                      >> public:
                      >> typedef std::auto_ptr<R ow> row_ptr;
                      >>
                      >> row(): row_base() {}
                      >>
                      >> row(row_state status, bool modified=false) :
                      >> row_base(status , modified) {}
                      >>
                      >> virtual ~row() {}
                      >>
                      >> static row_ptr create(pqxx::re sult::const_ite rator row,
                      >> pqxxobject::tra nsaction& tran)
                      >> {
                      >> row_ptr p(new Row);
                      >> p->convert_impl(r ow, tran); // protected
                      >> p->row_base::m_st ate = STATE_INITIALIS ED; // private
                      >> return p;
                      >> }
                      >>
                      >> virtual void convert_impl(pq xx::result::con st_iterator row,
                      >> pqxxobject::tra nsaction& tran) = 0;
                      >>
                      >> }; // class row
                      >>
                      >> Here, in the static create() method, row_base::m_sta te is a private
                      >> (enum) data member of the base class, yet I can assign it directly.
                      >> However, convert_impl() is a pure virtual function which is public
                      >> here and protected in the deriving class, but I get an error when I
                      >> compile:[/color][/color]
                      [...][color=blue][color=green]
                      >> I can't see the rationale between being able to access private data
                      >> members, but not protected methods (which are actually public in the
                      >> row<> class)![/color]
                      >
                      > They are public in the row<> class, but you are declaring your pointer
                      > as row_ptr, which in your case is an auto_ptr<Place> . So you're
                      > accessing the object through a pointer to Place, where, as you say, the
                      > member is protected, i.e. only Place itself and classes derived from
                      > that can access it.[/color]

                      Ah, that makes sense!

                      I've now got it working, but only after discovering a wart in the
                      language: the base class is a template and if I declare a pure virtual
                      (or virtual) function in the template, when I call the function it
                      does not call the derived version. It appears that virtual does not
                      work with templates at all :-\.

                      I've come up with two solutions: declare the function in the deriving
                      class public, so the template can call it directly (not desirable), or
                      keep it protected/private and make the base class a friend, so it can
                      call them even though they are protected (better, but still not
                      clean enough for my liking).

                      Is there a better alternative to these approaches? Basically, I'd
                      like to be able to fake virtual to achieve this effect:

                      template<typena me T>
                      class foo {
                      public:
                      void func() { func_impl(); }
                      private:
                      virtual void func_impl();
                      }

                      class bar : public foo<int> {
                      private:
                      virtual void func_impl();
                      }

                      i.e. when I do this:
                      bar c;
                      c.func()
                      c.func_impl() gets called by foo<int>::func( ).

                      Thanks,
                      Roger

                      --
                      Roger Leigh

                      Printing on GNU/Linux? http://gimp-print.sourceforge.net/
                      GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.


                      -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                      http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                      -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                      Comment

                      • Jeff Schwab

                        #12
                        Re: static member functions access to class members and methods

                        Roger Leigh wrote:
                        [color=blue]
                        > I did get a copy of Stroustrup's TCPL from the library at the same
                        > time, but as a C programmer with no OO knowledge, I was out of my
                        > depth several pages into the introduction!! It would probably be OK
                        > now I have a decent grasp of the language, but the 21 days books was
                        > far more understandable at the time.[/color]

                        Try skipping the intro. If you already have some familiarity with C,
                        the first few chapters of TC++PL should be mostly review for you, and
                        get you up to speed quickly on C++ as a "better C."

                        Comment

                        Working...