answersLogoWhite

0

A struct in C is a POD (plain old data) type. A class in C++ can also be a POD for backward compatibility with C code, but more typically combines data with methods that operate upon the data, including constructors and initialisers.

Classes in C++ can be declared using either the struct or class keyword. By convention you will typically use struct to define POD data types and class to define more complex data types.

The only practical difference between a struct and a class is that classes use private access and inheritance by default while struct uses public access and inheritance by default. Thus the following two class definitions are functionally the same:

struct A {

A():m_data(0) {} // public access by default

private:

int m_data;

};

class B {

int m_data; // private access by default

public:

B():m_data(0) {}

};

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

Can a c plus plus class be derived from a Java class?

No.


Basic control structure available in c plus plus?

The basic control structure in C++ is the if statement.


How will you compare turbo c to c plus plus?

"http://wiki.answers.com/Q/How_will_you_compare_turbo_c_to_c_plus_plus_language"


What is the role of object in c plus plus?

An object in C++ is an instance of a C++ class.


What is the Cdacl in c plus plus?

It's a wrapper for a discretionary access control list (DACL) structure. It is not part of the C++ standard, it's a Microsoft-specific class. Consult the MSDN for more information.


How will you compare turbo c to c plus plus language?

"http://wiki.answers.com/Q/How_will_you_compare_turbo_c_to_c_plus_plus_language"


What is the name of the structure type in C plus plus?

The same as in C, struct.


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 nested class in c plus plus?

s.


What is the unit of programming in c plus plus A. Function B. class C. object D. Attribute?

B. Class.


Basic structure of c n c plus plus?

The basic structure of a C or C++ program is built around types. A structure is a type. A function is a type. A class is a type. All of these types can be built from primitive (built-in) types and can be used to create ever-more complex types.


What is a method in c plus plus?

In C++, methods are simply class member functions.