answersLogoWhite

0


Best Answer

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

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a class in c plus plus how does it compare with structure in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Basic control structure available in c plus plus?

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


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

No.


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 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.


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

The same as in C, struct.


What is the role of object in c plus plus?

An object in C++ is an instance of a C++ 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.


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 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.


Do I need structure of turbo c plus plus?

Yes.


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.