code not working on xcode

hello, i am a beginner in C++
this is the code i wrote for finding largest number using xcode IDE
it doesnt show any errors, but doesnt give output either.
here is the output:
enter the value of and b 1 4
The largest value is:
0Program ended with exit code: 0

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
#include<iostream>
using namespace std;
class LargestValue
{
public:
    int a;
    int b;
    int large;
    int input(void);
    int largest(void);
    int display(void);
};
int LargestValue::input(void)
{
    std::cout<<"enter the value of and b";
    std::cin>>a>>b;
    return (static_cast<void>(a),b);
}
int LargestValue::largest(void)
{
    if (a>b)
    {large=a;
        return a;}
        large=b;
    return b;
}
int LargestValue::display(void)
{
    std::cout<<"The largest value is:\n"<<large;
    return large;
}
int main(int argc, const char * argv[])
{
    LargestValue A;
    A.input();
    A.display();
    A.largest();
    return 0;
}
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
#include <iostream>

class LargestValue
{
private:
   int a;
   int b;
   int large;

public:
   void input();
   void largest();
   void display();
};

int main()
{
   LargestValue A;

   A.input();

   A.largest();

   A.display();
}


void LargestValue::input()
{
   std::cout << "enter the value of and b: ";
   std::cin >> a >> b;
}

void LargestValue::largest()
{
   if (a > b)
   {
      large = a;
   }
   large = b;
}

void LargestValue::display()
{
   std::cout << "The largest value is: " << large << '\n';
}

enter the value of and b: 5 12
The largest value is: 12
thank youu!!
Ooops, I must have been severely caffeine deprived when I looked at your code.

largest() will always select b as the largest value even if it isn't.

34
35
36
37
38
void LargestValue::largest()
{
   if (a > b) { large = a; }
   else       { large = b; }
}
Topic archived. No new replies allowed.