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;
}

Recommended Answers

All 3 Replies

So, is there any problem with the code ??

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

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.