C++
How does a ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
How does a constant object initializing if the
const
qualifier prohibits the compiler to change it on the stage of creating?
All objects are initially created as non-constants
With the help of constructor marked by
const
qualifier
When creating the compiler is allowed to modify constant objects
None of the above
Explanation
All objects are initially created as non-constant, they initializing, and then constancy "hangs" on constant objects.
const-cast
constant
const-qualifier
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
В каких строках код содержит ошибки инициализации: float f(int); class Obj { public: static const int temp1 = 7; // 1 static int temp2 = 11; // 2 const int temp3 = 13; // 3 static const int temp4 = f(17); // 4 static const float temp5 = 7.0 // 5 };
char * const a, b; Какой тип теперь имеют a и b?
В каких строках возникнет ошибка компиляции? void foo(int const* x, int* const y){ int a; *x = 5; //1 x = &a; //2 *y = 5; //3 y = &a; //4 } int main() { int x,y; foo(&x,&y); }
Если для одного из полей константного объекта необходима возможность изменения этого поля, то следует ... (выберите корректный способ)
1 int main() 2 { 3 const int* i = int(); 4 int const* j = int(); 5 int* const k = int(); 6 int* l(); 7 8 ++i; 9 ++j; 10 ++k; 11 ++*k; 12 ++l; 13 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции?
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C++ quizzes
int main() { const int* i = int(); // 1 int const* j = int(); //2 int* const k = int(); //3 int* l(); //4 ++i; //5 ++j; //6 ++k; //7 ++*k; //8 ++l; //9 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции? После стандарта C++14.
Какой результат работы программы? #include <iostream> using namespace std; void f(double) { cout<<"f1"<<endl; } void f(const int ) { cout<<"f2"<<endl; } void f( int & ) { cout<<"f3"<<endl; } void main(void) { int n = 1; double b = 2; f(n); f(b); }
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment