answersLogoWhite

0

In C#, a struct is a Value type derived from Object, and provides no inheritance.

A class is also derived from Object but as a Referencetype, also allow subtypes to be drived from a class, unless it is declared as sealed.

That is, a struct like:

public struct A {}

and

a class like:

public sealed class B {}

Are almost the same, except when an instance being passed as an argument to a method, an instance of A is passed by value, while an instance of B is passed by reference (by default).

A class can be declared as abstract, while a struct cannot be one.

class provides a class hierarchy (yes you can build a class tree), while struct is a flat and boring 1-level sealed module unit (but as a value type).

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the Difference between b and c class MS pipe?

The main difference is the thickness of the pipe Compare to A Class pipe B Class pipe thickness is more.Like that Compare to B class pipe C Class pipe thickness is more.


What is the difference between Google Class A and Class C shares?

The main difference between Google Class A and Class C shares is in their voting rights. Class A shares come with voting rights, allowing shareholders to have a say in company decisions, while Class C shares do not have voting rights.


What are the differences between a C structure and C class?

The main difference between a class and a structure is that structures are always public whereas classes are private by default. Classes give greater control as the interface can be engineered such that only code that requires access to specific class members gains that access. Everything else can be hidden within the class itself. Note that C does not support classes, period. Classes are only supported by C++. However C++ also supports C structures for backward compatibility with C-style code.


What is the difference between a class A felony and a class C?

Class A is the most serious and has more severe penalties.


What is the difference between structure and class with example?

Structures are public by default whereas classes are private by default. Other than that they are exactly the same. struct s { int num; // s.num is accessible outside of the structure }; class c { int num; // c.num is only accessible to the class itself. };


What is the difference between a structure in C and a structure in C-plus-plus?

Not much. C++ structures are the same, i.e., still declared with "struct".. Are you sure that you didn't mean to ask: "What's the difference between a structure and a class?" Cause, that's the main (DRUMROLL PLEASE) power of C++, among other things. I think there is a difference in them. In struct of C there are no Member functions allowed .( you can use function pointer but not the definition in the structure ). But in C++ you have that flexibility . A C++ struct is exactly the same as a C++ class, except that struct members are public by default while class members are private by default. Access to individual members can be overridden in the declaration thus either can be used for the same purpose. C++ programmers use classes to define most object types and reserve the struct type for backward-compatibility with C.A C struct has member variables but has no methods. Accessibility cannot be defined, thus all members are effectively public at all times.


What is the difference between a class method and object in object-oriented C?

Class methods are the member functions that act upon member variables. An object is an instance of a class. C does not support object-oriented programming, but C++ does.


Defference between c plus plus and c?

these are difference in between c and c++: a) C is a SPL and C++ is a OOP. b) C has not concept of object but C++ has this feature. c) C has not 'class' name data type but C++ has.


What is the difference between an attribute and a behavior in c plus plus?

An attribute is a class member variable while a behaviour is a class member method.


What are the advantages of structure in c plus plus?

They are primarily included to retain compatibility with C. However, structures are public by default. So if you don't require the data hiding capability of a class, a struct is a suitable alternative. Also, when mixing C and C++ code, there may be a requirement to typecast a class to a struct and vice versa.


What is the difference between a class A B and C drug?

Class A drugs are the drugs that are most dangerous for example cocaine. Class B drugs are the drugs that are mildly dangerous. Class C drugs are the drugs that are least dangerous for example cannabis.


What the difference between c and c plus plus?

The fundamental difference is that in C++ object-oriented programming (OOP) was added. C is a procedural language (that means. top-down structure design), where as C++, which is an extension of C itself, is an object oriented language.