Learn C++

12.9 — Pointers and const

Consider the following code snippet:

With normal (non-const) pointers, we can change both what the pointer is pointing at (by assigning the pointer a new address to hold) or change the value at the address being held (by assigning a new value to the dereferenced pointer).

However, what happens if the value we want to point at is const?

The above snippet won’t compile -- we can’t set a normal pointer to point at a const variable. This makes sense: a const variable is one whose value cannot be changed. Allowing the programmer to set a non-const pointer to a const value would allow the programmer to dereference the pointer and change the value. That would violate the const-ness of the variable.

Pointer to const value

A pointer to a const value (sometimes called a pointer to const for short) is a (non-const) pointer that points to a constant value.

To declare a pointer to a const value, use the const keyword before the pointer’s data type:

In the above example, ptr points to a const int . Because the data type being pointed to is const, the value being pointed to can’t be changed.

However, because a pointer to const is not const itself (it just points to a const value), we can change what the pointer is pointing at by assigning the pointer a new address:

Just like a reference to const, a pointer to const can point to non-const variables too. A pointer to const treats the value being pointed to as constant, regardless of whether the object at that address was initially defined as const or not:

Const pointers

We can also make a pointer itself constant. A const pointer is a pointer whose address can not be changed after initialization.

To declare a const pointer, use the const keyword after the asterisk in the pointer declaration:

In the above case, ptr is a const pointer to a (non-const) int value.

Just like a normal const variable, a const pointer must be initialized upon definition, and this value can’t be changed via assignment:

However, because the value being pointed to is non-const, it is possible to change the value being pointed to via dereferencing the const pointer:

Const pointer to a const value

Finally, it is possible to declare a const pointer to a const value by using the const keyword both before the type and after the asterisk:

A const pointer to a const value can not have its address changed, nor can the value it is pointing to be changed through the pointer. It can only be dereferenced to get the value it is pointing at.

Pointer and const recap

To summarize, you only need to remember 4 rules, and they are pretty logical:

  • A non-const pointer can be assigned another address to change what it is pointing at.
  • A const pointer always points to the same address, and this address can not be changed.
  • A pointer to a non-const value can change the value it is pointing to. These can not point to a const value.
  • A pointer to a const value treats the value as const when accessed through the pointer, and thus can not change the value it is pointing to. These can be pointed to const or non-const l-values (but not r-values, which don’t have an address).

Keeping the declaration syntax straight can be a bit challenging:

  • A const before the asterisk is associated with the type being pointed to. Therefore, this is a pointer to a const value, and the value cannot be modified through the pointer.
  • A const after the asterisk is associated with the pointer itself. Therefore, this pointer cannot be assigned a new address.

guest

Next: volatile , Up: Type Qualifiers   [ Contents ][ Index ]

21.1 const Variables and Fields

You can mark a variable as “constant” by writing const in front of the declaration. This says to treat any assignment to that variable as an error. It may also permit some compiler optimizations—for instance, to fetch the value only once to satisfy multiple references to it. The construct looks like this:

After this definition, the code can use the variable pi but cannot assign a different value to it.

Simple variables that are constant can be used for the same purposes as enumeration constants, and they are not limited to integers. The constantness of the variable propagates into pointers, too.

A pointer type can specify that the target is constant. For example, the pointer type const double * stands for a pointer to a constant double . That’s the type that results from taking the address of pi . Such a pointer can’t be dereferenced in the left side of an assignment.

Nonconstant pointers can be converted automatically to constant pointers, but not vice versa. For instance,

This is not an ironclad protection against modifying the value. You can always cast the constant pointer to a nonconstant pointer type:

However, const provides a way to show that a certain function won’t modify the data structure whose address is passed to it. Here’s an example:

Using const char * for the parameter is a way of saying this function never modifies the memory of the string itself.

In calling string_length , you can specify an ordinary char * since that can be converted automatically to const char * .

const pointer assignment

How to Use const Qualifier With Pointers in C++

  • How to Use const Qualifier With Pointers …

Use the const type var Notation to Declare Read-Only Object in C++

Use the const qualifier with pointers to handle read-only objects in c++.

How to Use const Qualifier With Pointers in C++

This article will demonstrate multiple methods about how to use a const qualifier with pointers in C++.

The C++ provides the keyword const as the qualifier for objects that need to be defined as read-only (immutable). const variables are declared with the notation const type var or type const var , both of which are syntactically correct, but the former one is used as conventional style. Since const qualified objects are not mutable, they must be initialized during the declaration. This makes a statement const int number; - invalid and throws compiler error (probably your IDE will also scream about it).

When the const variable is initialized, it can not be assigned a different value during run-time. Thus, the third line in the following example’s main function is invalid, and the compiler won’t process it. Note that if you declare a pointer to the same type of a variable and then try to assign the address of the const variable to it, the error is reported by the compiler. Note that the latter error is usually overridden if we compile with the -fpermissive flag.

The const qualifier is often used with pointers. There are three types of declarations const type * var , type *const var and const type *const var . The first declares the var pointer to read-only type object, meaning that the object can’t be modified but the pointer itself can be. The second - var read-only pointer to type object, where we declare unique, an immutable pointer to the object that can be modified, and the last one defines the both - pointer and the object as immutables.

These notations provide multiple useful features that are explored in the following code samples. As shown in the last example, we couldn’t store the address of the const variable in a non-const pointer, but if we add the const specifier, the operation is valid. Mind though, we still can’t modify stored value via newly declared pointer as demonstrated in the 4th line of the main loop:

Another common issue while using the const qualifier with pointers is non-const pointers’ assignment to the pointers that point to the read-only objects. Notice that, there’s a new non-const variable number2 initialized in the next code example, and the c_ptr that was declared as a pointer to const object, is now assigned with the address of number2 . This operation is legal in C++, and the consequence is that we can only read the value stored in the number2 variable via c_ptr , but any modifications will result in a compiler error.

Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

Related Article - C++ Const

  • Const at the End of Function in C++
  • The const Keyword in C++
  • How to Use the const Keyword With Pointers in C++

Related Article - C++ Pointer

  • Dangling Pointers in C++
  • Declaration and Uses of unique_ptr in C++
  • Function Pointer to Member Function in C++
  • How to Swap Two Numbers Using Pointers in C++
  • Void Pointer in C++
  • Functionality and Difference Between *& and **& in C++

Pointers in C / C++ [Full Course] – FREE

const pointer assignment

Const Pointer in C++

In this lecture, we discuss about Const pointer and Pointer to Const and Const Pointer to Const in C++.

Why do we need Const Pointer or Pointer to Const?

A pointer is a variable that stores the memory address of another variable or the memory address of the memory allocated on the heap. For example,

Here, we have created a variable ‘num’ and initialized it with the value 11, then created a pointer ‘ptr’ and initialized it with the address of variable ‘num’. Now, the pointer ‘ptr’ contains the memory location where the value of the variable ‘num’, i.e. 11, is stored.

You can access this value using the pointer ‘ptr’ by dereferencing it. Like this,

You can also change the value at that memory location. For example, you could change the value at the memory location pointed to by ‘ptr’ to 20, which in turn would change the value of variable ‘num’. You can print and confirm that the value of the variable ‘num’ is now 20.

This is how you change the value at a memory location using a pointer.

Now, suppose you pass a pointer to a function and, inside the function, someone changes the value. This value change inside the function using the pointer will be reflected outside the function as well. For example, if you have a variable ‘num’, initialized with the value 11, and then create a pointer ‘ptr’ containing the address of this variable, if you then pass this pointer to the function ‘getSquare’, this function is supposed to return the square of the value at the memory location pointed to by the given pointer. But if a new developer comes along and tries to change the value at this location pointed to by the pointer, because you passed a pointer, he can directly change the value.

We wanted the square of 11, but inside the function value at memory location got changed to 2, and it returned the square of 2 instead. Also after the function getSquare() returns, the value of num is also changed to 2.

Pointer to Const in C++

You can restrict the user from changing the value pointed to by the pointer by using a pointer to const. While creating a pointer, you can make the pointer point to a const integer. In both cases, the pointer ‘ptr’ will be pointing to a memory location, but it cannot change the data at that memory location. So, if someone tries to change the value now, it will give an error. Similarly, if you want to pass a pointer to a function for read operation only, then you can pass it like this.

Here, you are passing a pointer pointing to a const integer, so nobody can change the value at that memory location using the pointer. This is called pointer to const.

Even if you restricted the user so that they cannot change the value at the memory location pointed to by the pointer ‘ptr’, the pointer itself is also a variable, so you can change it to point to a new memory location. Check out this example: here, inside the ‘getSquare()’ function, we change the value of the pointer ‘ptr’ and make it point to a new memory location.

Is there any way to restrict the user so that they can’t change the pointer to point to a new memory location? Answer is Yes, by making pointer a constant pointer.

To restrict the user so they cannot make the pointer point to another memory location, you need to make the pointer const, like this.

Here, your pointer is a const pointer pointing to a memory location, or the address of variable ‘num’. Now, even if you want to point the pointer to a new memory location, you can’t do that because the pointer is of const type. However, using the pointer, you can change the value at that memory location, as the pointer is not pointing to a constant integer. This is different from the previous scenario.

Const pointer pointing to Const in C++

In this section, we will cover a combination of both: a const pointer pointing to a constant integer. Suppose you initialize the variable ‘num’ with the value 11. Now, you want to create a pointer to this but you want to restrict it so that no one can change the value of ‘num’ using the pointer, and also, once you initialize the pointer to the address of ‘num’, no one can make that pointer point to any other location. For that, you have to use a const pointer pointing to a const value, like this.

Here, your pointer ‘ptr’ is a const pointer and is pointing to a constant value. So, we cannot make the pointer point to any other location, and we also cannot use the pointer to change the value at that memory location.

Const pointer vs Pointer to Const vs Const Pointer to Const

Sure, here’s a simple table to illustrate the differences:

const pointer assignment

  • A const pointer means that the memory location that the pointer is pointing to can be changed, but the pointer itself cannot change and point to a different memory location. In other words, the pointer is constant, but the data at which it points is not.
  • A pointer to const means that the pointer can point to different locations, but the data at the memory location the pointer is pointing to cannot be changed using this pointer. In other words, the data is constant but the pointer is not.
  • A const pointer to const combines both concepts – the pointer cannot point to a different memory location and the data at the memory location cannot be changed. Both the pointer and the data it points to are constant.

In this lecture, we learned about Const pointer and Pointer to Const and Const Pointer to Const in C++.

  • C++ Language
  • Ascii Codes
  • Boolean Operations
  • Numerical Bases

Introduction

Basics of c++.

  • Structure of a program
  • Variables and types
  • Basic Input/Output

Program structure

  • Statements and flow control
  • Overloads and templates
  • Name visibility

Compound data types

  • Character sequences
  • Dynamic memory
  • Data structures
  • Other data types
  • Classes (I)
  • Classes (II)
  • Special members
  • Friendship and inheritance
  • Polymorphism

Other language features

  • Type conversions
  • Preprocessor directives

Standard library

  • Input/output with files

Address-of operator (&)

const pointer assignment

Dereference operator (*)

const pointer assignment

  • & is the address-of operator , and can be read simply as "address of"
  • * is the dereference operator , and can be read as "value pointed to by"

Declaring pointers

Pointers and arrays, pointer initialization, pointer arithmetics.

const pointer assignment

Pointers and const

Pointers and string literals.

const pointer assignment

Pointers to pointers

const pointer assignment

  • c is of type char** and a value of 8092
  • *c is of type char* and a value of 7230
  • **c is of type char and a value of 'z'

void pointers

Invalid pointers and null pointers, pointers to functions.

Mead's Guide to const

"The road to hell is paved with global variables" -- Steve McConnell

Introduction to const

Simple Uses of const (C and C++)

/* Globals */ int gi; /* 1. gi is initialized to 0 */ int gj = 10; /* 2. gj is initialized to 10 */ const int gci; /* 3. Illegal, gci must be initialized */ /* Locals */ void constvalues( void ) { int i; /* 4. i is uninitialized (garbage) */ int j = 5; /* 5. j is initialized to 5 */ const int ci; /* 6. Illegal, ci must be initialized */ const int ci2 = 10; /* 7. Ok, ci2 is initialized to 10 */ const int ci3 = ci2; /* 8. Ok, ci3 is initialized to 10 */ const int ci4 = j; /* 9. Ok, ci4 is initialized to 5 */ i = 20; /* 10. Ok, assignment of 20 to i */ j = 12; /* 11. Ok, assignment of 12 to j */ ci2 = 10; /* 12. Illegal, can't assign to a const */ }

Pointers and const (C and C++)

int *pi; /* pi is a (non-const) pointer to a (non-const) int */
const int *pci; /* pci is a pointer to a const int */
int * const cpi = &i; /* cpi is a const pointer to an int */
const int * const cpci = &ci; /* cpci is a const pointer to a const int */
const int * pci; int const * pci;
int * const cpi = &i;
*pci; /* *pci is a constant int */ *cpi; /* *cpi is an int */
*pci = 5; /* ILLEGAL, can't assign to a constant */ *cpi = 5; /* OK, you can assign to a non-constant */
void foo( void ) { int i = 5; /* 1. i is a non-constant int */ int j = 6; /* 2. j is a non-constant int */ const int ci = 10; /* 3. ci is a constant int */ const int cj = 11; /* 4. cj is a constant int */ int *pi; /* 5. pi is a pointer to an int */ const int *pci; /* 6. pci is a pointer to a const int */ int * const cpi = &i; /* 7. cpi is a const pointer to an int */ const int * const cpci = &ci; /* 8. cpci is a const pointer to a const int */ i = 6; /* 9. Ok, i is not const */ j = 7; /* 10. Ok, j is not const */ ci = 8; /* 11. ERROR: ci is const */ cj = 9; /* 12. ERROR: cj is const */ pi = &i; /* 13. Ok, pi is not const */ *pi = 8; /* 14. Ok, *pi is not const */ pi = &j; /* 15. Ok, pi is not const */ *pi = 9; /* 16. Ok, *pi is not const */ pci = &ci; /* 17. Ok, pci is not const */ *pci = 8; /* 18. ERROR: *pci is const */ pci = &cj; /* 19. Ok, pci is not const */ *pci = 9; /* 20. ERROR: *pci is const */ cpi = &j; /* 21. ERROR: cpi is const */ *cpi = 10; /* 22. Ok, *cpi is not const */ *cpi = 11; /* 23. Ok, *cpi is not const */ cpci = &j; /* 24. ERROR: cpci is const */ *cpci = 10; /* 25. ERROR: *cpci is const */ pi = &ci; /* 26. DANGER: constant ci can be changed through pi */ }
Note the last line in the code says DANGER. In C, this is a warning, but in C++, this is an error. Important: If you have a constant object, you can only point at that object with a pointer that is declared to point at a constant. This means that you can not point at the constant object with a pointer that is NOT declared as pointing to a constant object. See #26 above. Consider this C warning as an error, because it should be.
/* i is non-const and can be changed through the variable name */ int i = 5; /* Ok, but i can't be changed through the pointer (but not really useful, since i isn't constant) */ const int *pci = &i; /* Ok, i is not const, so it can be changed */ i = 8; /* ERROR: can't change object that pci points to */ *pci = 8;
Also realize that a pointer does not affect the object it's pointing at . In the example above, the pointer, pci does not make i constant. The variable i is not constant, and will never be constant. The pointer, pci , just means that you can't change i through the pointer. You can only change i directly (through i ).

Protecting Function Arguments (C and C++)

Unsafe Safe /* Modifies the array the was passed in!! */ --> int find_largest1( int a[], int size) { int i; int max = a[0]; /* assume 1st is largest */ /* change first element! */ --> for (i = 1; i < size; i++) { if (a[i] > max) max = a[i]; /* found a larger one */ /* set element to 0!! */ --> } return max; }
/* Unable to modify the array since it's const */ --> int find_largest2( const int a[], int size) { int i; int max = a[0]; /* assume 1st is largest */ a[0] = 0; /* ILLEGAL: elements are const */ --> for (i = 1; i < size; i++) { if (a[i] > max) max = a[i]; /* found a larger one */ a[i] = 0; /* ILLEGAL: elements are const */ --> } return max; }
/* array of const integers will never change */ const int a[] = {4, 5, 3, 9, 5, 2, 7, 6}; /* array of non-const integers that can change */ int b[] = {4, 5, 3, 9, 5, 2, 7, 6}; int largest1, largest2; largest1 = find_largest1(a, 8); /* Compiler Error, function claims it will modify the array */ largest2 = find_largest2(a, 8); /* OK */ largest1 = find_largest1(b, 8); /* OK */ largest2 = find_largest2(b, 8); /* OK */
void some_function( const int array[], int size);
void some_function( const Foo* object);
void some_function( const Foo& object);

Protecting Returned Data (C and C++)

Returning Non-constant Pointers/References (C and C++)

/* This function is not changing the array itself, but it is potentially */ /* allowing other code to change it by returning a non-const pointer to */ /* an element of the array. Because of the potential for other code to */ /* change the array, the parameter must be non-const. */ int *get_largest( int a[], int size) { int i; int max = 0; for (i = 1; i < size; i++) if (a[i] > a[max]) max = i; /* return pointer to max element */ return &a[max]; }
void Test( void ) { int i; int a[] = {4, 5, 3, 9, 5, 2, 7, 6}; /* Get a pointer to the largest int */ int *p = get_largest(a, 8); /* Set the element to 0 */ *p = 0; print_array1(a, 8); /* No "extra" pointer required */ *get_largest(a, 8) = 0; print_array1(a, 8); /* Set largest to 0, one at a time */ for (i = 0; i < 6; i++) { *get_largest(a, 8) = 0; print_array1(a, 8); } }
Output : 4 5 3 0 5 2 7 6 4 5 3 0 5 2 0 6 4 0 3 0 5 2 0 0 4 0 3 0 0 2 0 0 0 0 3 0 0 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0

Protecting Class Member Data (C++ only)

#include "Bar2.h" void TestBar3( void ) { Bar2 b1(1, 2); // non-const const Bar2 b2(3, 4); // const // Will b1's data members be changed? Doesn't // matter since it is not a constant object. b1.Print(); // Will b2's data members be changed? It matters because // it is a constant object and the compiler needs to be sure. b2.Print(); // ERROR }
void Print( void ) const ;
void Bar2::Print( void ) const { std::cout << "Bar->a is " << a_ << std::endl; std::cout << "Bar->b is " << b_ << std::endl; /* ERROR, the compiler will catch this and prevent it. */ a_ = 5; }

Constants and Arrays: C vs. C++

The C Way The C++ Way #define SIZE 5 int a[SIZE];
const int size = 5; int b[size];
warning: ISO C90 forbids variable length array 'b' [-Wvla]

Global Constants: C vs. C++ (A Subtle Difference)

int foo = 1; /* Definition */ int bar = 2; /* Definition */ int baz = 3; /* Definition */ int foo = 1; /* Re-definition */
error: redefinition of 'foo'
file1.c file2.c #include <stdio.h> int foo = 5; void fn( void ); /* Prototype */ int main( void ) { fn(); printf( "foo is %i\n" , foo); return 0; }
#include <stdio.h> int foo = 5; void fn( void ) { printf( "foo is %i\n" , foo); }
/tmp/ccYXh9oj.o:(.data+0x0): multiple definition of 'foo'
file1.cpp file2.cpp #include <stdio.h> const int foo = 5; void fn( void ); /* Prototype */ int main( void ) { fn(); printf( "foo is %i\n" , foo); return 0; }
#include <stdio.h> const int foo = 5; void fn( void ) { printf( "foo is %i\n" , foo); }
gcc -Wall -Wextra -ansi -pedantic -x c++ file1.c file2.c
gcc -Wall -Wextra -ansi -pedantic -x c file1.cpp file2.cpp
  • Why did things change and why is this a big deal?
  • Global constants are meant for the entire program (otherwise they wouldn't be global).
  • Global constants are meant to replace the #define directive.
  • This means that global constants are meant to be placed in header files (which will be included by all of the files in a project).
const int UP_ARROW = 78; const int DOWN_ARROW = 79; const int LEFT_ARROW = 80; const int RIGHT_ARROW = 81; const int HOME = 90; const int END = 92; const int ESC = 27; const int BACKSPACE = 26; /* Many more below */

For More Information

cppreference.com

Pointer declaration.

Pointer is a type of an object that refers to a function or an object of another type, possibly adding qualifiers. Pointer may also refer to nothing, which is indicated by the special null pointer value.

[ edit ] Syntax

In the declaration grammar of a pointer declaration, the type-specifier sequence designates the pointed-to type (which may be function or object type and may be incomplete), and the declarator has the form:

where declarator may be the identifier that names the pointer being declared, including another pointer declarator (which would indicate a pointer to a pointer):

The qualifiers that appear between * and the identifier (or other nested declarator) qualify the type of the pointer that is being declared:

The attr-spec-seq (C23) is an optional list of attributes , applied to the declared pointer.

[ edit ] Explanation

Pointers are used for indirection, which is a ubiquitous programming technique; they can be used to implement pass-by-reference semantics, to access objects with dynamic storage duration , to implement "optional" types (using the null pointer value), aggregation relationship between structs, callbacks (using pointers to functions), generic interfaces (using pointers to void), and much more.

[ edit ] Pointers to objects

A pointer to object can be initialized with the result of the address-of operator applied to an expression of object type (which may be incomplete):

Pointers may appear as operands to the indirection operator (unary * ), which returns the lvalue identifying the pointed-to object:

Pointers to objects of struct and union type may also appear as the left-hand operands of the member access through pointer operator -> .

Because of the array-to-pointer implicit conversion, pointer to the first element of an array can be initialized with an expression of array type:

Certain addition, subtraction , compound assignment , increment, and decrement operators are defined for pointers to elements of arrays.

Comparison operators are defined for pointers to objects in some situations: two pointers that represent the same address compare equal, two null pointer values compare equal, pointers to elements of the same array compare the same as the array indexes of those elements, and pointers to struct members compare in order of declaration of those members.

Many implementations also provide strict total ordering of pointers of random origin, e.g. if they are implemented as addresses within continuous ("flat") virtual address space.

[ edit ] Pointers to functions

A pointer to function can be initialized with an address of a function. Because of the function-to-pointer conversion, the address-of operator is optional:

Unlike functions, pointers to functions are objects and thus can be stored in arrays, copied, assigned, passed to other functions as arguments, etc.

A pointer to function can be used on the left-hand side of the function call operator ; this invokes the pointed-to function:

Dereferencing a function pointer yields the function designator for the pointed-to function:

Equality comparison operators are defined for pointers to functions (they compare equal if pointing to the same function).

Because compatibility of function types ignores top-level qualifiers of the function parameters, pointers to functions whose parameters only differ in their top-level qualifiers are interchangeable:

[ edit ] Pointers to void

Pointer to object of any type can be implicitly converted to pointer to void (optionally const or volatile -qualified), and vice versa:

Pointers to void are used to pass objects of unknown type, which is common in generic interfaces: malloc returns void * , qsort expects a user-provided callback that accepts two const void * arguments. pthread_create expects a user-provided callback that accepts and returns void * . In all cases, it is the caller's responsibility to convert the pointer to the correct type before use.

[ edit ] Null pointers

Pointers of every type have a special value known as null pointer value of that type. A pointer whose value is null does not point to an object or a function (dereferencing a null pointer is undefined behavior), and compares equal to all pointers of the same type whose value is also null .

To initialize a pointer to null or to assign the null value to an existing pointer, a null pointer constant ( NULL , or any other integer constant with the value zero) may be used. static initialization also initializes pointers to their null values.

Null pointers can indicate the absence of an object or can be used to indicate other types of error conditions. In general, a function that receives a pointer argument almost always needs to check if the value is null and handle that case differently (for example, free does nothing when a null pointer is passed).

[ edit ] Notes

Although any pointer to object can be cast to pointer to object of a different type, dereferencing a pointer to the type different from the declared type of the object is almost always undefined behavior. See strict aliasing for details.

lvalue expressions of array type, when used in most contexts, undergo an implicit conversion to the pointer to the first element of the array. See array for details.

Pointers to char are often used to represent strings . To represent a valid byte string, a pointer must be pointing at a char that is an element of an array of char, and there must be a char with the value zero at some index greater or equal to the index of the element referenced by the pointer.

[ edit ] References

  • C17 standard (ISO/IEC 9899:2018):
  • 6.7.6.1 Pointer declarators (p: 93-94)
  • C11 standard (ISO/IEC 9899:2011):
  • 6.7.6.1 Pointer declarators (p: 130)
  • C99 standard (ISO/IEC 9899:1999):
  • 6.7.5.1 Pointer declarators (p: 115-116)
  • C89/C90 standard (ISO/IEC 9899:1990):
  • 3.5.4.1 Pointer declarators

[ edit ] See also

  • Recent changes
  • Offline version
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link
  • Page information
  • In other languages
  • This page was last modified on 15 June 2021, at 08:34.
  • This page has been accessed 68,822 times.
  • Privacy policy
  • About cppreference.com
  • Disclaimers

Powered by MediaWiki

const pointer assignment

  • my_c++_journey
  • Jun 26, 2019
  • 5 minutes read

const pointer assignment

Using const key word with a pointer has subtle aspects and it is worth talking about it.

  • Point-to-const or const pointer

You can use the const keyword in two different ways with pointers.

The first way is to make a pointer point to a constant object, and that prevents you from using the pointer to change the pointed-to value. The second way is to make the pointer itself constant, and that prevents you from changing where the pointer points.

This words are subtle and confusing the first time I read them especially after I read some examples about assignment and changeability. However, once I know the purpose of using const key word, things become crystal clear.

So, why are we using const to pointer? The answer is simple: we want to protect the data. Specifically, the data could be value or address. So when you use the const key word, you should ask yourself the question first, which one would you want to protect, the value or the address?

If you want to protect the value, you should make a pointer point to a constant object. You tell the compiler, this pointer point to some value that you’d better not make a change. It means even you have the pointer, you can not change the value through pointer, because the value is now protected.

If you want to protect the address, you should make the pointer itself constant. You tell the compiler this pointer is binding to some address and you’d better not change it. It is more like binding the relationship between the pointer and the value it point to.

  • pointer to constant
assigning the address of a const variable to a pointer-to-const.

you can use neither value nor ptr to change the value 9.80. You can not do the following things

assigning the address of a regular variable to a pointer-to-const.

you can not use ptr to change the value 50, but you can directly change the value through variable “value”. You can not do the following things

This case is tricky. It is often used in the cases which you have a function and pass a pointer as the argument. In this case, you do not want the function to change the value that the pointer point to. You want to protect the value, how can you do that? Right, let the pointer be a pointer-to-const.

assigning the address of a const to a regular pointer.

This is prohibit in c++, because you can use a regular pointer to change the value it point to, however, if the value is decleared constant, it comes to a contradiction.

assign the address of a regular pointer to a pointer-to-const

This is not safe. Not recommend.

So to wrap up,

You can assign the address of either const data or non-const data to a pointer-to-const, provided that the data type is not itself a pointer, but you can assign the address of non-const data only to a non-const pointer.
ok to change the pointer itself, can change to point to another value

It just protect the value, you can not change the value through pointer, but it does not protect the address(pointer itself), you can change the address to point to another value.

  • make the pointer itself constant

Ptr restrain to the address of value.

Here is a picture from book “ C++ Primer Plus ”.

const pointer and pointer to const

  • Const pointer that point to a const object

If you like, you can declare a const pointer to a const object which combines the properties above:

Here ptr can point only to trouble, and ptr cannot be used to change the value of trouble. In short, both ptr and *ptr are const.

  • C++
  • - CATALOG -

Join us on Facebook!

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. By using our site, you acknowledge that you have read and understand our Privacy Policy , and our Terms of Service . Your use of this site is subject to these policies and terms. | ok, got it

— Written by Triangles on December 10, 2018 • updated on March 08, 2019 • ID 68 —

Constant pointers vs. pointer to constants in C and C++

Pointer, constant pointer, pointer to constant, constant pointer to constant: what else?

This is a topic that always confused me since the beginning: it's time to figure it out for good. In C and C++ you can have pointers that point to objects. But also constant pointers to objects. Or pointers to constant objects. Or even both. What's the real difference?

The easiest way to tackle the const/non-const pointer issue is to find out the different combinations. You have two actors here: the pointer and the object pointed to . How they can interact together:

  • neither the pointer nor the object is const;
  • the object is const;
  • the pointer is const;
  • both the pointer and the object are const.

Let's take a int as an example. Those different possibilities can be expressed as follows:

Now, suppose you have a simple structure defined like this:

from which you instantiate two objects:

Let's see what you can do by mixing the four possibilities listed above.

1. Pointer to object

Both the pointer and the object are writable. You can modify the object, e.g. changing its x value and you can also modify the pointer, e.g. assign it a new object:

2. Pointer to const object

You can modify the pointer but you can't modify the object:

3. Const pointer to object

You can't modify the pointer but you can modify the object:

4. Const pointer to const object

You can't do anything here, except for reading the object value:

StackOverflow - What is the difference between const int , const int const, and int const *? StackOverflow - Constant pointer vs pointer on a constant value

  • Hispanoamérica
  • Work at ArchDaily
  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Letovo Schoolcampus / atelier PRO

Letovo Schoolcampus / atelier PRO - Windows, Facade

  • Curated by Fernanda Castro
  • Architects: atelier PRO
  • Area Area of this architecture project Area:  39000 m²
  • Year Completion year of this architecture project Year:  2018
  • Photographs Photographs: NARODIZKIY , Dmitry Voinov , atelier PRO
  • Interior Design : Atelier PRO , Thijs Klinkhamer
  • Landscape Designer : Buro Sant en Co
  • Client:  Letovo
  • Project Architects:  Dorte Kristensen, Pascale Leistra, Karho Yeung
  • Design Team:  Thijs Klinkhamer, Abel de Raadt, Alessia Topolnyk
  • Russian Co Architect:  Atrium, Moscow
  • City:  Moscow
  • Country:  Russia
  • Did you collaborate on this project?

Letovo Schoolcampus / atelier PRO - Windows, Facade

Text description provided by the architects. The official grand opening of a special school, Letovo School , took place in Moscow last September. The assignment entailed a 20 hectare schoolcampus with educational facilities, student housing and school staff housing. The school campus offers extended outdoor sports facilities with a soccer stade, a running track, tennis courts and basketball courts. In addition there is a greenhouse, a treeyard and ample space for wandering and relaxation in the green.

Letovo Schoolcampus / atelier PRO - Image 2 of 36

While the architecture and interior of the school were designed by atelier PRO, the landscape design was developed by Buro Sant en Co landscape architecture. Russian firm Atrium Architectural Studio was responsible for the technical execution. In 2014 Atelier PRO had won the international design competition, the construction began mid-2016 and the campus was taken into use by mid-2018.

Letovo Schoolcampus / atelier PRO - Windows, Column

Letovo, a dream come true Letovo School is a special school for gifted and motivated children aged 12 to 17. The idea to create the school came from entrepreneur and philanthropist Vadim Moshkovich: ‘My dream was to offer talented children from all over the country access to high-quality education, regardless of their parents’ financial means. This school makes it possible for them to continue their studies at the 10 best universities in the country or at one of the top 50 universities in the world.’

Letovo Schoolcampus / atelier PRO - Windows, Facade

Landscape-inspired design and shape Located in Novaya Moskva,southwest of Moscow ,the campus sits atop a beautiful plot of land that slopes down to a forest-lined river. Distinctive level variations were applied in and around the school to integrate the architecture into the landscape.

Letovo Schoolcampus / atelier PRO - Windows, Facade

The shape of the large complex brings it down to a human scale for the children: the building appears to dance across the landscape due to its dynamic design. Due to the perspective effect one only ever sees part of the building's full size when walking around, which gives the impression of a refined scale. The building’s contours and flowing curves create surprising indoor and outdoor spaces as well.

Letovo Schoolcampus / atelier PRO - Chair

The heart of the school: the central hub The central hub is the place where day-to-day life at the school unfolds. This flexible, transformable space will be used throughout the day as an informal meeting place. The dance studio on the ground floor can be transformed through a few simple adjustments into a theatre with a stage, a cosy living room or an auditorium that can accommodate 1,000 people for special events such as graduation ceremonies and large celebrations, as seen at the grand opening. This central hub connects the building’s three wings: the art wing, the south wing with science- and general-use rooms and the sports wing

Letovo Schoolcampus / atelier PRO - Windows, Facade

Learning environment with a diversity in working spaces Letovo envisioned an innovative and modern take on existing education in Russia. In the spatial design, this perspective translates into space for theoretical education as well as special areas for group work and independent study in the tapered building wings. In the library wing there are silence spaces workshop spaces and a debating room. These are all supportive to the student’s personal development. 

Letovo Schoolcampus / atelier PRO - Image 13 of 36

Sports programme In addition to the extended sports outdoor facilities, the indoor supply of sports facilities is substantial. These cover fitness rooms, martial arts rooms, a swimming pool, a small and a large sports hall. Around the sports hall there’s an indoor running track which can be used throughout the year. It is available to school staff and external users as well.

Letovo Schoolcampus / atelier PRO - Image 14 of 36

The interior, also designed by atelier PRO, is tailored to the aims of the ambitious programme. The design of the interior also focuses extensively on the various spaces where students can go to chill and meet up with friends. The extreme cold in this area makes the school’s indoor atmosphere important for relaxation.

const pointer assignment

Ambitous learning environment The Russian client has established a private, non-profit school which aims to be the most prestigious school in the country and to offer the best educational programme through a Russion and an IB (International Baccalaureate) curriculum. Students’ personal development is paramount, with the school adopting a holistic approach. It is a true learning environment that provides scope for a range of disciplines, areas of interest and recreational opportunities to foster children’s development. This aim is supported by the campus facilities and functions.

Letovo Schoolcampus / atelier PRO - Image 24 of 36

Project gallery

Letovo Schoolcampus / atelier PRO - Windows, Facade

Project location

Address: zimenkovskaya street, sosenskoye settlement, moscow, russia.

Click to open map

Materials and Tags

  • Sustainability

世界上最受欢迎的建筑网站现已推出你的母语版本!

想浏览archdaily中国吗, you've started following your first account, did you know.

You'll now receive updates based on what you follow! Personalize your stream and start following your favorite authors, offices and users.

Check the latest Desks

Check the latest Desk Accessories

  • Bahasa Indonesia
  • Slovenščina
  • Science & Tech
  • Russian Kitchen

Now and then: What Moscow looked like when it was rural (PHOTOS)

const pointer assignment

Moscow was not built at once - the ancient city is still expanding, annexing new villages and towns. In total, over 220 rural settlements became Moscow districts, but the exact number of them is hard to estimate. Active development of the outskirts started in 1960, when it became necessary to solve housing (many people lived in communal apartments) and traffic (with the construction of the Moscow Ring Road) problems. Then, Moscow, with its six million inhabitants, increased almost twice in size and its new districts filled up with panel houses , which defined the appearance of ANY residential area in Russia until recently. By the 1980s, when the number of official residents exceeded eight million, Moscow went beyond the Moscow Ring Road, joining the districts of Butovo, Zhulebino and others. And, in 2012, the 12 million-people strong Moscow increased by almost 2.5 times again, annexing several towns up to the border with Kaluga Region, thereby becoming Europe’s largest city. Today’s residential areas include lots of high-rises, shopping malls, parks and public sites. We’ve chosen seven villages to compare how they look - then and now.

Left: A cow in the Belyayevo-Bogorodskoye village, 1968; Right: A 30-meters-graffiti devoted to the FIFA 2018 championship at the Profsoyuznaya street.

Left: A cow in the Belyayevo-Bogorodskoye village, 1968; Right: A 30-meters-graffiti devoted to the FIFA 2018 championship at the Profsoyuznaya street.

Between 1960-1986, several neighboring villages became the new Konkovo district in the south-west of Moscow (where you will find subway stations Kaluzhskaya, Belyaevo and Konkovo) with its main highway, Profsoyuznaya Street. This is a very beautiful area, where you won’t find industrial territories; instead, there are lots of parks, hills and old churches. It’s a pleasure to walk around Konkovo! In old photos, you can see that while they were building panel houses, cows were still grazing around them. 

2. Kozhukhovo

Above: The village of Kozhukhovo in 1951. Below: Alexander Nevsky church in Kozhukhovo.

Above: The village of Kozhukhovo in 1951. Below: Alexander Nevsky church in Kozhukhovo.

This is one of the oldest villages in Moscow, which has been known since the 15th century and, since 1923, was included in Moscow. Kozhukhovo in the south-east of the city had its own railway station even in tsarist times, but the log houses remained here until the 1970s, when the area was finally surrounded by concrete buildings. 

3. Troparyovo

Above: Wooden houses of the Troparevo village, 1978. Below: Troparevo metro station, 2019.

Above: Wooden houses of the Troparevo village, 1978. Below: Troparevo metro station, 2019.

Troparyovo district in the southwest of the city was built on the site of the village, which became Moscow in 1960. The name came from its first ruler, boyar (a noble) Ivan Tropar (the word ‘tropar’ means a religious song in a church), who was buried here in 1393. During the Soviet years, there was a big kolkhoz (collective farm) with good transport connection, a school and a store. The last wooden houses were demolished in 1981. And, in 2014, a metro station was opened. 

4. Chertanovo

Above: Chertanovo airfield, mid-1960. Below: A park in Chertanovo, 2010.

Above: Chertanovo airfield, mid-1960. Below: A park in Chertanovo, 2010.

The former village of Chertanovo in the south of Moscow became its part in 1960. Besides a kolkhoz and other agricultural areas, in the 1940s-1960s, there was an airfield where you could learn to fly a glider. Then the village began to be built up with panel houses and the northern part of Chertanovo was even designed as a model neighborhood and considered a “Soviet paradise”, which could be shown to guests of the 1980 Olympic Games. (Read more about that here ) 

5. Cherkizovo

const pointer assignment

Above: Old houses in Cherkizovo, 1964. Below: Bolshaya Cherkizovskaya street, 2009.

The old village of Cherkizovo-Podmoskovnye in the east of Moscow became part of the city in the early 20th century, but, until the 1970s, it still resembled a village with its wooden houses and gardens. Now, Cherkizovo is included in the Preobrazhenskoe District and the village’s name remains in the names of several streets and subway stations. You will also find the preserved Church of Elijah the Prophet, built in 1690. 

6. Cheryomushki

Above: The village of Cheryomushki, 1954. Below: A new house in Cheryomushki, built on the place of old panel houses, 2020.

Above: The village of Cheryomushki, 1954. Below: A new house in Cheryomushki, built on the place of old panel houses, 2020.

In 1956-1959, the village of Cheryomushki in the south-west of Moscow was the area of the first housing development made up of ‘Khrushchyovkas’ buildings. It became a part of Moscow in 1958. The experimental site consisted of 13 four-storey and seven eight-storey buildings. The pilot apartments were tiny, but facades were decorated with brick, the courtyards had real fountains and pergolas for plants and the development had its own stores, canteens and even a cinema. (read more about it here ) 

Today many old ‘Khrushchyovkas’ in this district are replaced with new multi-storey buildings with big apartments and modern infrastructure. 

7. Kuryanovo

const pointer assignment

Left: Kuryanovo in 1967. Right: Kuryanovo railway station.

If you wondered where the time stopped in Moscow, it’s in the village of Kuryanovo (in the southeast) that has been part of the city since 1960. Kuryanovo is bordered from the city by the railways and going there is like taking a little trip to the Soviet past. In this area, most residential buildings are still two-storeyed with many gardens in the backyards. And here’s a big Lenin’s monument in the center of the district. Locals like their neighborhood for its authenticity.

Left: A postman talks with locals in the village of Vykhino, 1944. Right: A pond in the Vykhino-Zhulebino district.

Left: A postman talks with locals in the village of Vykhino, 1944. Right: A pond in the Vykhino-Zhulebino district.

In 1960, the village of Vykhino in southeastern Moscow joined the city. The old settlement, together with the Lenin collective farm, was demolished and residents were moved from their log huts to modern panel houses. Today, Vykhino is one of the largest districts of Moscow, where more than 220,000 people live. 

9. Kommunarka

Above: Dairy farm of the Kommunarka sovkhoz, 1968. Below: New residential area.

Above: Dairy farm of the Kommunarka sovkhoz, 1968. Below: New residential area.

One of the main districts of so-called ‘New Moscow’ became the settelment  of Kommunarka in 2012. In Soviet times, there was a large sovkhoz, which fell into disrepair with the collapse of the USSR. Today, the main street of the area is named after the last sovkhoz head, Alexandra Monakhova. The district it is very actively built up - in a few years, here appeared about hundred new houses. A subway station opened there in 2019. 

10. Vatutinki

Left: A house with the stove heating in Vatutinki, 1965. Right: A sports park and the new houses, 2020.

Left: A house with the stove heating in Vatutinki, 1965. Right: A sports park and the new houses, 2020.

Vatutinki is another ‘New Moscow’ settlement, which joined Moscow in 2012. It’s as much as 17 kilometers to the MKAD (Moscow Ring Road). Before 2012, Vatutinki was the home to about 10,000 people and today, there are about 35,000 inhabitants. The population is constantly growing, moving into new houses. 

A little blue house found itself on the grounds of a new housing development in the Moscow Region.

A little blue house found itself on the grounds of a new housing development in the Moscow Region.

The owners of these old wooden houses refused to sell when real estate developers moved in. Take a look at the last villages surrounded by concrete giants. 

Dear readers,

Our website and social media accounts are under threat of being restricted or banned, due to the current circumstances. So, to keep up with our latest content, simply do the following:

  • Subscribe to our   Telegram   channel
  • Subscribe to our   weekly email newsletter
  • Enable push notifications on our   website
  • Install a VPN service on your computer and/or phone to have access to our website, even if it is blocked in your country

If using any of Russia Beyond's content, partly or in full, always provide an active hyperlink to the original material.

to our newsletter!

Get the week's best stories straight to your inbox

  • Can you believe less than 50 years ago Moscow looked like a village?
  • The 7 most beautiful villages in Russia (PHOTOS)
  • 6 places in Russia where you will feel like you’re in another country (PHOTOS)

const pointer assignment

This website uses cookies. Click here to find out more.

You are using an outdated browser. Please upgrade your browser .

Russian Tours and Cruises from Express to Russia

Moscow International Business Center (Moscow City)

  • Guide to Russia

What can you do at Moscow City?

  • Dine in style: Moscow City is home to 100+ cafes and restaurants, including Europe’s highest restaurant and ice-cream shop
  • See Moscow like never before: Ascend to one of Moscow City’s observation decks for an unparalleled panorama of Moscow
  • Admire world-class architecture: Each of Moscow City’s skyscrapers has distinctive architecture and design
  • Learn something new: Visit the Museum of High-Rise Architecture in Moscow or the Metro Museum

Moscow City is a multifunctional complex in the west of Moscow, which has come to represent the booming business of Russia’s capital. Its skyscrapers enrich Moscow’s skyline, contrasting the medieval cupolas and Stalinist high-rises. Visitors to Moscow City can enjoy entertainment high in the sky, as the complex is home not just to offices, but to restaurants, cinemas, viewing platforms, and museums.

Moscow International Business Center (Moscow City)

Photo by Alex Zarubi on Unsplash

History of Moscow City

Moscow City was first conceived in 1991 by honoured Soviet architect Boris Tkhor, who proposed to construct a business center in Moscow. It would be complete with gleaming skyscrapers rivalling those of New York and London, to reflect the new life and growing ambitions of post-Soviet Russia.

The chosen site was a stone quarry and disused industrial zone in western Moscow, in between the Third Ring Road and Moskva River. Initially, the territory was divided into 20 sections arranged in a horseshoe shape around a central zone. The skyscrapers would increase in height as they spiralled around the central section, with shorter structures built on the waterfront to give the taller buildings behind a view of the river. 

Architect Gennady Sirota, who contributed to iconic projects such as the Olympic Sports Complex on Prospekt Mira, was selected as the chief architect, and many other world-famous architects were attracted to Moscow to realise their visions in Moscow City.

What can you see and do at Moscow City?

Where Moscow’s cityscape was once dominated by Stalin’s Seven Sisters skyscrapers , this is no more. Moscow City is home to eight of Russia’s ten tallest buildings, six of which exceed 300 metres in height. More buildings are still under construction there today, including the One Tower (which will be Europe’s second-tallest building). Once completed, Moscow City will comprise more than 20 innovative structures.

Each of Moscow City’s skyscrapers was designed by its own architect, lending the cluster of skyscrapers a unique appearance. Aside from being a site of architectural wonder, Moscow City is a place for leisure and entertainment with over 100 cafes and restaurants, exhibition spaces, cinemas, viewing platforms, and more.

Photo by Nikita Karimov on Unsplash

Federation Tower

  • East Tower: 374m, 97 floors; West Tower: 243m, 63 floors
  • Completed in 2017
  • Architects: Sergey Tchoban and Peter Schweger

The East Federation Tower is the tallest building in Moscow, and the second-tallest building in Europe after the Lakhta Centre in St Petersburg. Visitors can enjoy a luxurious meal of seafood, truffles or steak at restaurant ‘Sixty’ on the 62nd floor of the West Tower, or visit Europe’s highest observation deck, ‘Panorama 360’, on the 89th floor of the East Tower.

Did you know? The ice cream and chocolate shop on the 360 observation deck are the highest in the world!

  • South Tower: 354m, 85 floors; North Tower: 254m, 49 floors
  • Completed in 2015
  • Architect: Skidmore, Owings & Merrill LLP

The South OKO Tower is the third-tallest building in Russia and Europe. Here, you can visit ‘Ruski’ to dine on hearty Russian cuisine cooked on a real Russian stove, and have a drink in the ice bar. Alternatively, visit restaurant, nightclub and performance space ‘Birds’; the restaurant is the highest in Europe, situated on the 86th floor roof terrace alongside an observation deck. The OKO Towers are also home to karaoke club ‘City Voice’.

Did you know? Underneath OKO Towers is the largest underground parking in Europe, with 16 levels and 3,400 parking spaces.

Mercury Tower

  • 339m tall, 75 floors
  • Architects : Mikhail Posokhin, Frank Williams, Gennady Sirota

Another multifunctional skyscraper, which was designed as the first truly ‘green’ building in Moscow. The Mercury Tower has a distinct geometric shape and copper-coloured glazing, and was the tallest building in Europe upon completion. Visit ‘More i myaso’ (Sea and meat) on the first floor of the tower to enjoy European and Mediterranean cuisine whilst surrounded by greenery. On the 2nd and 40th floors a modern art gallery, the ‘ILONA-K artspace’, has just opened.

City of Capitals

  • Moscow Tower: 302m, 76 floors; St Petersburg Tower: 257m, 65 floors
  • Completed in 2009
  • Architect: Bureau NBBJ

The unique geometric design of the City of Capitals towers resembles stacks of rotating blocks, and is rooted in Constructivism of the early Soviet period (many Soviet Constructivist buildings can be found in Moscow). Visitors to the Moscow Tower can enjoy a range of cuisines – traditional Italian dishes on the summer terrace of ‘Tutto Bene’, Panasian cuisine in the tropical luxury of the ‘Bamboo Bar’ on the 1st floor’, and poke or smoothie bowls at ‘Soul in the Bowl’ cafe on the 80th floor.

Tower on the Embankment

  • Tower A: 84m; Tower B:127m; Tower C: 268m, 61 floors
  • Completed in 2007
  • Architects: Vehbi Inan and Olcay Erturk

After completion, the Tower on the Embankment was the tallest building in Europe, and is now the 13th tallest. It houses the headquarters of several large Russian and international  companies, including IBM and KPMG. There are two cafes located on the 1st floor of Tower C – self-service café ‘Obed Bufet’ (Lunch Buffet) and Bakery Chain ‘Khleb Nasushchny’ (Daily Bread).

Evolution Tower

  • 255m tall, 54 floors
  • Architects: Philip Nikandrov and RMJM Scotland Ltd

Evolution is Moscow City’s most recognisable tower, and the 11th tallest building in Russia. Its façade is a true architectural marvel, comprising continuous strips of curved glazing spiralling high into  the sky. According to the architect, Philip Nikandrov, the spiral shape of the tower honours centuries of architectural design in Russia, from the onion domes of St Basil's Cathedral to Vladimir Shukhov’s Tatlin Tower, a masterpiece of Constructivist design. Outside the Evolution tower is a landscaped terrace and pedestrian zone descending to the Presnenskaya Embankment, which was also designed by Nikandrov.

Did you know? Moscow’s largest wedding palace was supposed to be built on the site of the Evolution tower, though the project was abandoned.

  • 239m tall, 60 floors
  • Completed in 2011

Imperia’s interesting design has a curved roof and an arched glass façade. Inside the tower are various cafes including ‘City Friends’ for all-day breakfasts and light lunches, ‘Mama in the City’ for simple meals of Russian cuisine, and ‘abc kitchen’ for European and Indian-inspired dishes. Alternatively, visit ‘High Bar’ on the 56th floor for cocktails with a view. In Imperia you’ll also find the Museum of High-Rise Construction in Moscow (suitably located on the 56th floor), and the Camera Immersive Theatre.

Did you know? Inside Vystavochnaya metro station is the Metro Museum , dedicated to the history of the beautiful Moscow Metro!

  • 130m tall, 26 floors
  • Completed in 2001
  • Architect: Boris Tkhor

Tower 2000 was Moscow City’s first tower. It stands on the opposite bank of the Moskva River, and houses a viewing platform from which visitors can admire an unparalleled panorama of Moscow City. The Bagration Bridge reaches across the river from the tower to Moscow City, and underneath are piers from where you can take boat trips.

Photo by Alexander Popov on Unsplash

Afimall is Moscow’s largest entertainment and shopping complex, home to 450 shops, cafes and restaurants, a cinema, and a virtual-reality game park. The shopping centre is located in the central section of Moscow City, and a cinema and concert hall are currently under construction there.

What’s nearby?

Sechenov Botanical Gardens: The botanical gardens of the First Moscow State Medical University was created for students’ training and research in 1946. Today it is open for free visits, and is home to a large arboretum.

Park Krasnaya Presnya: This park belonged to the Studenets estate of the Gagarin princes. It is a monument of 18th and 19th century landscaping, with Dutch ponds, ornate bridges, and tree-lined alleys. There are also sports facilities, sports equipment rental, and cafes.

Botanical Gardens

Photo by Akkit  on Wikipedia

Essential information for visitors

Website: https://www.citymoscow.ru/

Email: [email protected]

Phone: +7 (495) 730-23-33

Nearest metro: Mezhdunarodnaya (closest to the skyscrapers), Delovoy Tsentr (underneath Afimall), Vystavochnaya (closest to Expocentre)

Related Tours

Moscow - St. Petersburg 3-star cruise by Vodohod

Moscow - St. Petersburg 3-star cruise by Vodohod

This is our most popular cruise covering Moscow and St. Petersburg and all of the significant towns between these 2 cities. Besides the Two Capitals, you will visit the ancient towns of Uglich, Yaroslavl and Goritsy, the island of Kizhi, and Mandrogui village.

Cruise Ship

Two Capitals and the Golden Ring

Two Capitals and the Golden Ring

This tour covers the best sights of Moscow and St. Petersburg along with a trip to the Golden Ring - a group of medieval towns to the northeast of Moscow. Ancient Kremlins, onion-shaped domes and wooden architecture is just a small part of what awaits you on this amazing tour.

Accommodation

PRIVATE TOUR

Classic Moscow

Classic Moscow

This is our most popular Moscow tour that includes all the most prominent sights. You will become acquainted with ancient Russia in the Kremlin, admire Russian art in the Tretyakov Gallery, listen to street musicians as you stroll along the Old Arbat street, and learn about Soviet times on the Moscow Metro tour.

Our travel brands include

russianrail.com

Express to Russia

Join us on Facebook

We invite you to become a fan of our company on Facebook and read Russian news and travel stories. To become a fan, click here .

Join our own Russian Travel, Culture and Literature Club on Facebook. The club was created to be a place for everyone with an interest in Russia to get to know each other and share experiences, stories, pictures and advice. To join our club, please follow this link .

We use cookies to improve your experience on our Website, and to facilitate providing you with services available through our Website. To opt out of non-essential cookies, please click here . By continuing to use our Website, you accept our use of cookies, the terms of our Privacy Policy and Terms of Service . I agree

IMAGES

  1. Pointers and const in C++

    const pointer assignment

  2. Const Pointer in C

    const pointer assignment

  3. Pointer constant Vs constant pointer in C programming

    const pointer assignment

  4. Using const keyword with pointers

    const pointer assignment

  5. constant pointer & pointer to constant with simple example

    const pointer assignment

  6. Const Pointer in C++

    const pointer assignment

VIDEO

  1. pointerAssignment

  2. C Language || Pointers in C || Part-4: Pointer Assignment in C || Telugu Scit Tutorial

  3. C2019 12 09 const pointer

  4. What are Pointers? How to Use Them? and How they can Improve your C++ Programming Skills

  5. Learn to Code C++ Pointers: Pointer Assignment PartI

  6. Week6

COMMENTS

  1. c++

    Constant pointer is a pointer (a number - memory address) that cannot be changed - it always point to the same object given via initialization: int * const const_pointer = &some_int_var; // will be always pointing to this var. const_pointer = &some_other_var; // illegal - cannot change the pointer. *const_pointer = 2; // legal, the pointer is a ...

  2. 12.9

    Pointer and const recap. To summarize, you only need to remember 4 rules, and they are pretty logical: A non-const pointer can be assigned another address to change what it is pointing at. A const pointer always points to the same address, and this address can not be changed. A pointer to a non-const value can change the value it is pointing to.

  3. c++

    Assigning the pointer to 42 is legal but very likely to crash, since 42 is probably not an address you are allowed to read or write. You probably mean const int *i; *i = 42;, which is disallowed, because i points to a constant integer. You are correct regarding const int * const types. In that case, both the pointer and the pointee are const.

  4. const (GNU C Language Manual)

    The constantness of the variable propagates into pointers, too. A pointer type can specify that the target is constant. For example, the pointer type const double * stands for a pointer to a constant double. That's the type that results from taking the address of pi. Such a pointer can't be dereferenced in the left side of an assignment.

  5. C++ Reference

    Const Data with a Const Pointer. To combine the two modes of const-ness with pointers, you can simply include const for both data and pointer by putting const both before and after the *: const type * const variable = some memory address ; or. type const * const variable = some memory address ; Popular pages.

  6. How to Use const Qualifier With Pointers in C++

    Another common issue while using the const qualifier with pointers is non-const pointers' assignment to the pointers that point to the read-only objects. Notice that, there's a new non-const variable number2 initialized in the next code example, and the c_ptr that was declared as a pointer to const object, is now assigned with the address ...

  7. Const Pointer in C++

    Here, you are passing a pointer pointing to a const integer, so nobody can change the value at that memory location using the pointer. This is called pointer to const. Copy to clipboard. int num = 11; // Integer pointer pointing. // to the address of num. int * ptr = &num;

  8. Pointers

    This would assign the address of variable myvar to foo; by preceding the name of the variable myvar with the address-of operator (&), ... Pointers and const Pointers can be used to access a variable by its address, and this access may include modifying the value pointed. But it is also possible to declare pointers that can access the pointed ...

  9. Mead's Guide to const

    Notes: Protecting pointer/reference parameters to functions is the most common use of the const keyword.; Passing by value does not require const.; If the function must modify the data that the caller passes a pointer/reference to, you must not use const.; Passing large objects (of user-defined types, not built-in types) by value is expensive

  10. Pointers

    If the pointer is const, we can't assign a different address to it. The pointer will always point to the same part of memory. If the value is constant, we are able to assign a different address to the pointer, but we can't change the value it points to. Pitfalls Accessing uninitialized pointers . Pointers should always be initialized with a ...

  11. Pointer declaration

    Pointer declaration is a fundamental concept in C and C++ programming. It allows the creation of variables that store the address of another variable or function. Learn how to declare, initialize, and use pointers, as well as their syntax, types, and operators. Compare pointers with other C and C++ features, such as arrays, variadic functions, and atomic references.

  12. Understanding All the Details of C++ Const

    If CreateT() returns a const object, line 3 in the code above will be invoking copy assignment operator, whereas if it returns a non-const object it will be invoking move assignment operator. This is because the compiler will choose the copy assignment operator overload which accepts a const object reference.. So unless you're using an older version of C++ there's no reason to return a ...

  13. C++: const & pointer

    This is prohibit in c++, because you can use a regular pointer to change the value it point to, however, if the value is decleared constant, it comes to a contradiction. const int value = 50 ; int * ptr = &value; // INVALID. Example 4. assign the address of a regular pointer to a pointer-to-const. This is not safe.

  14. Constant pointers vs. pointer to constants in C and C++

    1. Pointer to object. Both the pointer and the object are writable. You can modify the object, e.g. changing its x value and you can also modify the pointer, e.g. assign it a new object: 2. Pointer to const object. You can modify the pointer but you can't modify the object: 3. Const pointer to object.

  15. Assignment of union containing const-qualifier member

    a union that has such const members, a = b can be expected to not. raise errors about const-correctness. It seems that a union only provides a view of the object. The union. object doesn't automatically become const qualified if a member. of the union is const-qualified. This seems to be the reason v.w = u.w. works; otherwise, that modification ...

  16. 392 Jobs in Moscow, Moscow City, Russia (4 new)

    Abbott. Today's 241 jobs in Moscow, Moscow City, Russia. Leverage your professional network, and get hired. New Moscow, Moscow City, Russia jobs added daily.

  17. Letovo Schoolcampus / atelier PRO

    The official grand opening of a special school, Letovo School, took place in Moscow last September. The assignment entailed a 20 hectare schoolcampus with educational facilities, student housing ...

  18. Now and then: What Moscow looked like when it was rural (PHOTOS)

    Vatutinki is another 'New Moscow' settlement, which joined Moscow in 2012. It's as much as 17 kilometers to the MKAD (Moscow Ring Road). Before 2012, Vatutinki was the home to about 10,000 ...

  19. c

    practice # gcc -Wall pointer_to_constant.c -o pointer_to_constant pointer_to_constant.c: In function 'main': pointer_to_constant.c:12: error: assignment of read-only location '*ptr' Hence here too we see that compiler does not allow the pointer to a constant to change the value of the variable being pointed. Quotation

  20. Moscow International Business Center (Moscow City)

    255m tall, 54 floors. Completed in 2015. Architects: Philip Nikandrov and RMJM Scotland Ltd. Evolution is Moscow City's most recognisable tower, and the 11th tallest building in Russia. Its façade is a true architectural marvel, comprising continuous strips of curved glazing spiralling high into the sky.

  21. assignment discards 'const' qualifier from pointer target type

    Here you assign extension to the const pointer file_name and then formally assign new values to *extension:. for (extension = file_name; *file_name != '\0'; file_name++, extension++) *extension = *file_name; But because extension points into the const declared file_name, assigning new values is illegal and that's why toe compiler warns you and of course it is right.