answersLogoWhite

0

Structure in c plus plus

Updated: 8/11/2023
User Avatar

Wiki User

11y ago

Best Answer

Structures are the same as classes in C++. The only difference is that structure members are public by default while class members are private by default, but both define a class of object and both are initialised via a class constructor initialisation list.

struct my_object

{

my_object(const int data): m_data(data) {}

private:

int m_data;

};

The above struct is no different to the following class:

class my_object

{

int m_data;

public:

my_object(const int data): m_data(data) {}

};

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Yes, C++ supports structures. The syntax is largely the same as in C, but conforms to the way in which classes are declared. You can still use the C-style declarations however.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Structure in c plus plus
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.


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

The same as in C, struct.


Do I need structure of turbo c plus plus?

Yes.


What is the price of the book data structure using c and c plus plus by tanenbaum?

225 Rs. after discount........


Can you give an example of a structure in C plus plus?

struct point { int x; int y; };


What is the general structure of a C plus plus Language?

The central feature of any C++ program is classes which can be used to express ideas directly in code.


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


How do you display stars in c plus plus using the if else structure and a for loop and you use void main?

It depends on what program you design really


What is the notation used to place block of statements in a looping structure in C plus plus?

for( ; ; ) { statement_block; } while( conditional_expression ) { statement_block; } do { statement_block; }while( conditional_expression )


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 b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c