Found 7346 Articles for C++

What are signed and unsigned keywords in C++?

Rishi Rathor
Updated on 10-Feb-2020 12:26:50

2K+ Views

All number types in C++ can either have a sign or not. For example, you can declare an int to only represent positive integers. Unless otherwise specified, all integer data types are signed data types, i.e. they have values which can be positive or negative. The unsigned keyword can be used to declare variables without signs.Example#include using namespace std; int main() {    unsigned int i = -1;    int x = i;    cout

What does the volatile keyword mean in C++?

Priya Pallavi
Updated on 10-Feb-2020 12:25:23

2K+ Views

volatile means two things −- The value of the variable may change without any code of yours changing it. Therefore whenever the compiler reads the value of the variable, it may not assume that it is the same as the last time it was read, or that it is the same as the last value stored, but it must be read again.- The act of storing a value to a volatile variable is a "side effect" which can be observed from the outside, so the compiler is not allowed to remove the act of storing a value; for example, if ... Read More

What does the restrict keyword mean in C++?

Nikitha N
Updated on 30-Jul-2019 22:30:21

1K+ Views

There's no such keyword in C++. List of C++ keywords can be found in section 2.11/1 of C++ language standard. restrict is a keyword in the C99 version of C language and not in C++.In C, A restrict-qualified pointer (or reference) is basically a promise to the compiler that for the scope of the pointer, the target of the pointer will only be accessed through that pointer (and pointers copied from it).C++ compilers also support this definition for optimization purposes, but it is not a part of the official language specification.

Why do we use const qualifier in C++?

Srinivas Gorla
Updated on 10-Feb-2020 12:24:08

2K+ Views

We use the const qualifier to declare a variable as constant. That means that we cannot change the value once the variable has been initialized. Using const has a very big benefit. For example, if you have a constant value of the value of PI, you wouldn't like any part of the program to modify that value. So you should declare that as a const.Objects declared with const-qualified types may be placed in read-only memory by the compiler, and if the address of a const object is never taken in a program, it may not be stored at all.  For ... Read More

Why do we use restrict qualifier in C++?

Abhinanda Shri
Updated on 30-Jul-2019 22:30:21

185 Views

There's no such keyword in C++. List of C++ keywords can be found in section 2.11/1 of C++ language standard. restrict is a keyword in the C99 version of C language and not in C++.In C, A restrict-qualified pointer (or reference) is basically a promise to the compiler that for the scope of the pointer, the target of the pointer will only be accessed through that pointer (and pointers copied from it).C++ compilers also support this definition for optimization purposes, but it is not a part of the official language specification.

How to write the first C++ program?

Sai Nath
Updated on 26-Feb-2020 11:25:44

17K+ Views

So you've decided to learn how to program in C++ but don't know where to start. Here's a brief overview of how you can get started.Get a C++ CompilerThis is the first step you'd want to do before starting learning to program in C++. There are good free C++ compilers available for all major OS platforms. Download one that suits your platform or you can use the tutorialspoint.com's online compiler on https://www.tutorialspoint.com/compile_cpp_online.phpGCC − GCC is the GNU Compiler chain that is basically a collection of a bunch of different compilers created by GNU. You can download and install this compiler ... Read More

How do I set up C/C++ on Eclipse in Windows?

Arushi
Updated on 26-Feb-2020 11:21:22

8K+ Views

Step 1 − Install MinGW GCC or Cygwin GCCTo use Eclipse for C/C++ programming, you need a C/C++ compiler. On Windows, you could install either MinGW GCC or Cygwin GCC. Choose MinGW if you are not sure, because MinGW is lighter and easier to install, but has fewer features.MinGW GCCTo install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program which should be named MinGW .exe.While installing MinGW, at a minimum, you must install gcc-core, gcc-g++, binutils, and the MinGW runtime, but you may ... Read More

Why do we use a volatile qualifier in C++?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

361 Views

volatile means two things − The value of the variable may change without any code of yours changing it. Therefore whenever the compiler reads the value of the variable, it may not assume that it is the same as the last time it was read, or that it is the same as the last value stored, but it must be read again. The act of storing a value to a volatile variable is a "side effect" which can be observed from the outside, so the compiler is not allowed to remove the act of storing a value; for example, ... Read More

Why do we use modifiers in C/C++?

Abhinaya
Updated on 26-Feb-2020 11:17:42

242 Views

A modifier is used to alter the meaning of the base type so that it works in accordance with your needs. For example, time cannot be negative and it makes sense to make it unsigned. C++ allows the char, int, and double data types to have modifiers preceding them. The data type modifiers are listed here −signedunsignedlongshortThe modifiers signed, unsigned, long, and short can be applied to integer base types. In addition, signed and unsigned can be applied to char, and long can be applied to double.The modifiers signed and unsigned can also be used as a prefix too long ... Read More

What is the type specifier for boolean in C++?

Govinda Sai
Updated on 26-Feb-2020 11:15:59

145 Views

The type specifier for boolean in c++ is bool. You can use it as −bool myBoolean = true;

Advertisements