CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 1 of 1

Hybrid View

  1. #1
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+) ovidiucucu has a reputation beyond repute (3000+)
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    7,888

    C++ Classes: Which are the differences between 'struct' and 'class'?

    Q: Which are the differences between struct and class?

    A: In C++ programming language, there is no difference between classes defined by using struct or class keywords, except the default access to members and base classes.
    • for struct the default access is public;
    • for class the default access is private.
    Examples
    1. Code:
      struct SFoo : Base
      {
         int m_foo;
         void Foo();
      };
      is equivalent to
      Code:
      struct SFoo : public Base
      {
      public:
         int m_foo;
         void Foo();
      };
    2. Code:
      class CFoo : Base
      {
         int m_foo;
         void Foo();
      };
      is equivalent to
      Code:
      class CFoo : private Base
      {
      private:
         int m_foo;
         void Foo();
      };

    See also
    Last edited by ovidiucucu; May 3rd, 2011 at 02:01 AM.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width