answersLogoWhite

0

How-to structure in c plus plus?

Updated: 8/10/2023
User Avatar

Wiki User

14y ago

Best Answer

A structure in C++ is nearly the same as a structure in C. struct abc {

int item1;

int item2;

... etc...

} mystructure; There are several differences. Two examples are... In C++, you get automatic typedef'ing, so that (in this example) you would not have to say struct abc mysecondstructure; - you can just say abc mysecondstructure;. In C++, structures are very similar to classes. In fact, structures are classes, which is why you get automatic typedef'ing.

User Avatar

Wiki User

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

Wiki User

14y ago

The header in C++ is C and ++ is the increment operator.

There are various header files in C++ used for different functions.

The most common ones are:

#include<iostream.h>

#include<conio.h>

#include<math.h>

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

A C++ header file (.hpp) typically contains declarations of functions and classes, while the implementation details are hidden in source files (.cpp). The cpp file must include the hpp file, but other files, including other headers, may include the hpp file if they require it. However, you cannot include the same header more than once in a single build, so you must enclose the header's content within a header inclusion guard. Thus for a header named utils.h, you would write the following:

#ifndef _UTILS_H_

#define _UTILS_H_

// ...actual header content goes here...

#endif _UTILS_H_

In other words, when the preprocessor encounters an #include<utils.h> directive for the first time, the _UTILS_H_ macro will not be defined, thus the preprocessor will define it, and then merge everything up to the #endif directive into the file that included it. All subsequent times, _UTILS_H_ will already be defined, thus everything up to the #endif directive is ignored.

Note that the preprocessor processes all the directives, stripping them completely from your code (along with all comments), to create the intermediate files that will actually be compiled by the compiler. Thus including a file with #include effectively inserts the content of that file in place of the directive, just as if you'd typed it out in full yourself. The inclusion guard simply ensures that the file is only ever included once, regardless of how many other files include that same file. When the preprocessor phase is complete, you will have a series of intermediate files with no directives and no comments. Your IDE may have an option that permits you to save these files so you may examine them. By default, the files are temporary and are deleted prior to linking the object files created by the compiler.

The actual content of the header can include any declarations you wish, whether they be constants, enumerations, function signatures, class declarations, variables and so on. You can also include definitions in a header, although it's generally better to keep the interface (the header) separate from the implementation, as it makes it much easier to hide the implementation details when building libraries. The only exceptions are incomplete types such as function templates and template classes, which must be defined in the header, since the compiler needs access to the implementation details when generating actual types from the template.

Declarations that include function definitions are implicitly candidates for inline expansion by the compiler. Where the definition is separate from the declaration, you may use the inline keyword to explicitly specify that a function is a candidate for inline expansion. It doesn't matter whether the inline keyword is used in the declaration or the definition, but for the sake of clarity, it's best to explicitly declare both as inline. Note that the inline keyword (explicit or implied) does not guarantee inline expansion -- it merely marks the function as a candidate for expansion. The compiler will ultimately decide if the expansion is of any real benefit.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How-to 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 freezing point of turpentine?

-15.25 C macro.lsu.edu/howto/solvents/Freezing%20Point.htm -15.25 C macro.lsu.edu/howto/solvents/Freezing%20Point.htm


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.


Code for 8086 assembler in C or C plus plus?

Yes, you can write an 8086-assembler in C or C++. It is not that easy, though.It is posible with asm or __asm__ directive with combination of volatile or __volatile__ for non memory affecting code.Sample:__asm__ ("mov %ax, %bx");Move content of ax registry to bx.Follow howto page for tutorial. http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html


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 )