• Advertisement

Archived

This topic is now archived and is closed to further replies.

In C++ do structs support inheritance?

This topic is 5285 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Both of this comments were gotten from the help file included with Microsoft Visual C++ .NET This is from the .net Sdk structure A user-defined value type. Like a class, structures can contain constructors, constants, fields, methods, properties, indexers, operators, and nested types. Unlike classes, however, structures do not support inheritance. and I get this too, this is from C++ Language Reference A structure type is a user-defined composite type. It is composed of fields or members that can have different types. In C++, a structure is the same as a class except that its members are public by default. So which is it? Are the same or not? [edited by - hellfire on September 2, 2003 1:38:52 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by hellfire
So which is it?

The MSDN quote is not referring to C++.

Share this post


Link to post
Share on other sites
In C, there is no such thing as inheritence at all....

In C++, structs are the exactly same thing as classes, except the default visibility of all members is public. In C++, structs use the same syntax as classes, they can have function members, they can inherit, etc.

/¯\_/¯\_/¯\_/¯\_/¯\_/¯\
"You TK''ed my chicken!"
\_/¯\_/¯\_/¯\_/¯\_/¯\_/

Share this post


Link to post
Share on other sites
quote:
Original post by hellfire
Both of this comments were gotten from the help file included with Microsoft Visual C++ .NET

This is from the .net Sdk

structure
A user-defined value type. Like a class, structures can contain constructors, constants, fields, methods, properties, indexers, operators, and nested types. Unlike classes, however, structures do not support inheritance.


This refers to a .NET value type, which is called a struct in C#. It is not the same as a traditional C++ struct.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
So a the key word struct in C++ makes a subtype of class, where by default all data is public? Its not really a structure if we are talking about datatypes, like ques stacks and heaps?

Share this post


Link to post
Share on other sites

  • Advertisement