0

compare two value in oop based programing

#include<iostream>
using namespace std;
class com
{
private:
    int a;
    int b;
public:
    int d()
    {

        cin>>a;

        return 0;
    }
    int bd()
    {
        cin>>b;


        return 0;
    }

};
int main()
{
    com c1;


    if(c1.d()==c1.bd())
    {
        cout<<"y"<<endl;
    }
    else
    {
        cout<<"n"<<endl;
    }
    return 0;
}

Edited by Dani: Formatting fixed

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by jnabeel
0

You have c1.d() and c1.bd() BOTH returning zero. Instead you should return the values you read in, return a; or return b;

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.