Thread: C++ structs & inheritance, or something

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

    C++ structs & inheritance, or something

    What's this:
    Code:
    class DemoTree : public Gtk::TreeView
    {
      private:
        struct Columns : public Gtk::TreeModelColumnRecord             
        {
          Gtk::TreeModelColumn<Glib::ustring> column1;
          Gtk::TreeModelColumn<Glib::ustring> color;
          Columns() { add(column1);add(color); }
        };
        Columns columns;
    I mean, it looks like a struct definition, but what is the significance of the ": public Gtk::TreeModelColumnRecord"? (which a Gtk::TreeModelColumnRecord is not a struct...)
    Last edited by MK27; 03-29-2010 at 06:34 PM.
    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
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    A struct is a class, in C++....

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by tabstop View Post
    A struct is a class, in C++....
    makes sense. They should really make that clearer somewhere.
    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

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by MK27 View Post
    makes sense. They should really make that clearer somewhere.
    The difference is that structs have everything public by default and classes have everything private by default.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 09:04 AM
  3. inheritance and performance
    By kuhnmi in forum C++ Programming
    Replies: 5
    Last Post: 08-04-2004, 12:46 PM
  4. can you use inheritance with structs
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 05-26-2002, 09:31 AM
  5. Searching structs...
    By Sebastiani in forum C Programming
    Replies: 1
    Last Post: 08-25-2001, 12:38 PM