Archived

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

hellfire

In C++ do structs support inheritance?

Recommended Posts

hellfire    122
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
Tac-Tics    197
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
Arild Fines    968
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
hellfire    122
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