Dev C++ Terms

  1. All uses of the DEV logo, DEV badges, brand slogans, iconography, and the like, may only be used with express permission from DEV. DEV reserves all rights, even if certain assets are included in DEV open source projects. Please contact yo@dev.to with any questions or to request permission. Reserved Names.
  2. I have question regarding the licence terms. Is anykind restriction about software, developed by Dev-Cpp IDE put on it? (I don't mean to change source of Dev-Cpp, just write some commercial applications by it, without visibility or access to generated code of application of course).
  1. Dev C++ Terms Crossword
  2. Dev C Compiler
  3. Dev C++ Tutorial
  4. Dev C++ Download Windows 10
  5. Dev C++ Terms List
  6. Dev C++ Online

You agree to indemnify, and hold harmless DFS and each of its Affiliates, and any of their officers, directors, agents and employees, from and against any and all claims, actions, proceedings, and suits and all related liabilities, damages, settlements, penalties, fines, costs or expenses (including reasonable attorneys’ fees and other.

-->

A C++ program consists of various entities such as variables, functions, types, and namespaces. Each of these entities must be declared before they can be used. A declaration specifies a unique name for the entity, along with information about its type and other characteristics. In C++ the point at which a name is declared is the point at which it becomes visible to the compiler. You cannot refer to a function or class that is declared at some later point in the compilation unit. Variables should be declared as close as possible before the point at which they are used.

The following example shows some declarations:

On line 5, the main function is declared. On line 7, a const variable named pi is declared and initialized. On line 8, an integer i is declared and initialized with the value produced by the function f. The name f is visible to the compiler because of the forward declaration on line 3.

Dev C++ Terms Crossword

In line 9, a variable named obj of type C is declared. However, this declaration raises an error because C is not declared until later in the program, and is not forward-declared. To fix the error, you can either move the entire definition of C before main or else add a forward-declaration for it. This behavior is different from other languages such as C#, in which functions and classes can be used before their point of declaration in a source file.

In line 10, a variable named str of type std::string is declared. The name std::string is visible because it is introduced in the stringheader file which is merged into the source file in line 1. std is the namespace in which the string class is declared.

In line 11, an error is raised because the name j has not been declared. A declaration must provide a type, unlike other languages such as javaScript. In line 12, the auto keyword is used, which tells the compiler to infer the type of k based on the value that it is initialized with. The compiler in this case chooses int for the type.

Declaration scope

The name that is introduced by a declaration is valid within the scope where the declaration occurs. In the previous example, the variables that are declared inside the main function are local variables. You could declare another variable named i outside of main, at global scope, and it would be a completely separate entity. However, such duplication of names can lead to programmer confusion and errors, and should be avoided. In line 21, the class C is declared in the scope of the namespace N. The use of namespaces helps to avoid name collisions. Most C++ Standard Library names are declared within the std namespace. For more information about how scope rules interact with declarations, see Scope.

Definitions

Some entities, including functions, classes, enums, and constant variables, must be defined in addition to being declared. A definition provides the compiler with all the information it needs to generate machine code when the entity is used later in the program. In the previous example, line 3 contains a declaration for the function f but the definition for the function is provided in lines 15 through 18. On line 21, the class C is both declared and defined (although as defined the class doesn't do anything). A constant variable must be defined, in other words assigned a value, in the same statement in which it is declared. A declaration of a built-in type such as int is automatically a definition because the compiler knows how much space to allocate for it.

The following example shows declarations that are also definitions:

Here are some declarations that are not definitions:

Typedefs and using statements

In older versions of C++, the typedef keyword is used to declare a new name that is an alias for another name. For example the type std::string is another name for std::basic_string<char>. It should be obvious why programmers use the typedef name and not the actual name. In modern C++, the using keyword is preferred over typedef, but the idea is the same: a new name is declared for an entity which is already declared and defined.

Static class members

Because static class data members are discrete variables shared by all objects of the class, they must be defined and initialized outside the class definition. (For more information, see Classes.)

extern declarations

A C++ program might contain more than one compilation unit. To declare an entity that is defined in a separate compilation unit, use the extern keyword. The information in the declaration is sufficient for the compiler, but if the definition of the entity cannot be found in the linking step, then the linker will raise an error.

In this section

Storage classes
const
constexpr
extern
Initializers
Aliases and typedefs
using declaration
volatile
decltype
Attributes in C++

See also

Basic Concepts

  • C++ Basics
Dev C++ Terms
  • C++ Object Oriented
  • C++ Advanced
  • C++ Useful Resources
  • Selected Reading

When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what a class, object, methods, and instant variables mean.

Dev C Compiler

  • Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating. An object is an instance of a class.

  • Class − A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support.

  • Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.

  • Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

C++ Program Structure

Let us look at a simple code that would print the words Hello World.

Let us look at the various parts of the above program −

  • The C++ language defines several headers, which contain information that is either necessary or useful to your program. For this program, the header <iostream> is needed.

  • The line using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++.

  • The next line '// main() is where program execution begins.' is a single-line comment available in C++. Single-line comments begin with // and stop at the end of the line.

  • The line int main() is the main function where program execution begins.

  • The next line cout << 'Hello World'; causes the message 'Hello World' to be displayed on the screen.

  • The next line return 0; terminates main( )function and causes it to return the value 0 to the calling process.

Compile and Execute C++ Program

Let's look at how to save the file, compile and run the program. Please follow the steps given below −

Dev C++ Tutorial

  • Open a text editor and add the code as above.

  • Save the file as: hello.cpp

  • Open a command prompt and go to the directory where you saved the file.

  • Type 'g++ hello.cpp' and press enter to compile your code. If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file.

  • Now, type 'a.out' to run your program.

  • You will be able to see ' Hello World ' printed on the window.

Make sure that g++ is in your path and that you are running it in the directory containing file hello.cpp.

Terms

You can compile C/C++ programs using makefile. For more details, you can check our 'Makefile Tutorial'.

Semicolons and Blocks in C++

In C++, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

For example, following are three different statements −

A block is a set of logically connected statements that are surrounded by opening and closing braces. For example −

C++ does not recognize the end of the line as a terminator. For this reason, it does not matter where you put a statement in a line. For example −

is the same as

C++ Identifiers

A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).

C++ does not allow punctuation characters such as @, $, and % within identifiers. C++ is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C++.

Here are some examples of acceptable identifiers −

C++ Keywords

The following list shows the reserved words in C++. These reserved words may not be used as constant or variable or any other identifier names.

asmelsenewthis
autoenumoperatorthrow
boolexplicitprivatetrue
breakexportprotectedtry
caseexternpublictypedef
catchfalseregistertypeid
charfloatreinterpret_casttypename
classforreturnunion
constfriendshortunsigned
const_castgotosignedusing
continueifsizeofvirtual
defaultinlinestaticvoid
deleteintstatic_castvolatile
dolongstructwchar_t
doublemutableswitchwhile
dynamic_castnamespacetemplate

Trigraphs

A few characters have an alternative representation, called a trigraph sequence. A trigraph is a three-character sequence that represents a single character and the sequence always starts with two question marks.

Trigraphs are expanded anywhere they appear, including within string literals and character literals, in comments, and in preprocessor directives.

Dev C++ Download Windows 10

Following are most frequently used trigraph sequences −

TrigraphReplacement
??=#
??/
??'^
??([
??)]
??!|
??<{
??>}
??-~

Dev C++ Terms List

Dev C++ Terms

All the compilers do not support trigraphs and they are not advised to be used because of their confusing nature.

Whitespace in C++

Dev C++ Online

A line containing only whitespace, possibly with a comment, is known as a blank line, and C++ compiler totally ignores it.

Whitespace is the term used in C++ to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins.

Statement 1

In the above statement there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them.

Statement 2

In the above statement 2, no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose.