febb: (Default)
[personal profile] febb
Сделал такой C++ тест для сына. :)
Поглумиться над выросшим чадом - такая радость на старости лет :)
//--------------- Alex simple C++ test -----------------------

// Test 1: Is it something wrong here?
int a = a;
int b(b);

// Test 2: Are a,b,c,d the same?
A a;
A b = a;
A c;
A d(a);

// Test 3: Is it something wrong? What is the value of a and s?
A a1[10]; A a = a1[5]; int s = sizeof(a1); //1
A a2; A a = a2[5]; int s = sizeof(a2); //2

// Test 4: Can you compile this code? Explain.
A a(10); a = a(10);

// Test 5: What is value of i?
int i = !!!!!1!=!!!!!0;

// Test 6: Is it something wrong ?:
class A { int i; public: A(int i) : i(i) {} };

// Test 7: Is it something wrong ?:
class A { int i; A(int i) : i(i) { A(10); } };
A a;

// Test 8: Is it something wrong?:
int i = (i, 0, 1, 2, 3);

// Test 9: What is the value of i?
int i = 1>1>>1>>1>>1>1;

// Test 10: What is the value of d?
class A { operator int() { return 10; } };
A a; double d = a ? 0 : 1;

// Test 11: Is it something wrong here?
A a( );
A b = a;

P.S. Useful tutorial:
https://www.tutorialspoint.com/cplusplus/
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

febb: (Default)
febb

March 2022

S M T W T F S
  1 2 345
6 7 89 101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 10th, 2026 05:58 am
Powered by Dreamwidth Studios