How to manage bool function in abstract class ?

In my code below if true not returning 1 or 0 for false, please help.......

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <iterator>
#include <cstdlib>
#include <ctime>
using namespace std;

class Base
{
public :

 virtual bool MoveBlock(unsigned int x,unsigned int y)=0;
};

class Derived:public Base
{
    public:
 
bool MoveBlock(unsigned int x,unsigned int y)
{
    
    cout<<"Block moving logic"<<endl;
    
  int ar[4][4] = {
            {1, 2, 3, 4},
           {5, 6, 7, 8},
           {9, 10, 11, 12},
           {13, 14, 15, 0}
       };

       for (int row = 0; row < 4; ++row) {
           for (int col = 0; col < 4; ++col) {
               std::cout << ar[row][col] << ' ';
           }
           std::cout << std::endl;
       }
     int q;
     cin>>q;
     
     if(q==1)
     {
        int ar[4][4] = {
           {0, 1, 2, 3},
           {4, 5, 6, 7},
           {8, 9, 10, 11},
           {12,13, 14, 15,}
       };

       for (int row = 0; row < 4; ++row) {
           for (int col = 0; col < 4; ++col) {
               std::cout << ar[row][col] << ' ';
           }
           std::cout << std::endl;
       
       }
          cout<<"Block 1 is moved"<<endl;
          
              
        return true;
     }  
        else
        
           cout<<"B"<<endl;
           return false;
           
           
           }
};      

int main()
{
Base *b;
 Derived d;
 b = &d;
 b->MoveBlock(1,2);
 
 return 0;
}

How do you know that the function call on line 79 is not returning a value?
Because if true not showing 1
Where do you expect to see a 1? I added a cout statement on line 79 and it printed out a 1 at the end.

1
2
3
4
5
6
7
8
9
10
11
12
cout << b->MoveBlock(1,2);
Block moving logic
1 2 3 4 
5 6 7 8 
9 10 11 12 
13 14 15 0 
1
0 1 2 3 
4 5 6 7 
8 9 10 11 
12 13 14 15 
Block 1 is moved
1 
Thanks for the nice explanation :)
Topic archived. No new replies allowed.