What is the difference between c structure and c++ structure

Showing Answers 1 - 9 of 9 Answers

ritesh

  • Nov 10th, 2006
 

In C structure

1) We can not have access specifiers

2) Can not have functions.

But in C++

1) We can specify data and functions as public, Private or protected.

In C++ structure is also a class with Private as default access specifier

vishu

  • Jan 16th, 2007
 

no difference.... both are same.

  Was this answer useful?  Yes

dinesh

  • Jan 24th, 2007
 

c is structure oriented language whereas, c++ is object oriented i think this may be a difference

  Was this answer useful?  Yes

Vineet

  • Feb 11th, 2007
 

1> The data members in C++ structure are private by default while in C they are public .2> The structure variable initialization in C slso contains the struct keyword , while in C++ struct word is not required . 3>In C++ structures , we can have functions as members .

Salim

  • Aug 23rd, 2007
 

In c++ struct elements are 'public' by default

  Was this answer useful?  Yes

answer

  • Oct 12th, 2007
 

C++ structs are classes with default access as public.
C++ structs are types
C++ structs require a ;
C++ structs support ctors/dtors
C++ structs support explicit access specification
C++ structs support inheritance
C++ structs do not have tag names (they are already types)

C structs are simple maps of memory
C structs have tag names
C structs are not types (need to be typedef)

  Was this answer useful?  Yes

puneet83

  • Mar 30th, 2009
 

In C++ all the members of a structure are public by default as in case of C.

However, C++ structures can contain member functions whereas a structure in C can contain only data.

Structure in C++ are similar to a Class the only difference being that members of a class are private by default whereas menbers of a structure are public by default.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions