#include<iostream>
using namespace std;

class bank
{
    int a, b;

public :
    void add();
    friend int fnc(bank);

    friend void set_b(bank);
    int get_b();
};

void bank :: add()
{
    a = 50;
}
int fnc(bank x)
{
    return x.a;
}


void set_b(bank x)
{
    x.b = 100;
}
int bank :: get_b()
{
    return b;
}


int main()
{
    bank obj;

    obj.add();
    cout<<fnc(obj)<<endl;  // 1st output

    set_b(obj);
    cout<<obj.get_b()<<endl;   // 2nd output

    return 0;
}

asked 01 Aug, 20:14

Partho%20Debnath's gravatar image

Partho Debnath
233

edited 02 Aug, 04:33

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
1.1k18


b-এর ভ্যালু সেট হচ্ছে না, সে জন্য এই রকম হচ্ছে। আপনি গেটার-সেটার মেথড নিয়ে আরও পড়াশোনা করুন।

permanent link

answered 02 Aug, 04:49

menon's gravatar image

menon
4.8k743

edited 04 Aug, 07:56

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
1.1k18

ভাই, এইখানে b এর ভেলু সেট হচ্ছে না কেন একটু বুঝিয়ে বলবেন ?

(02 Aug, 07:29) Partho Debnath
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×139

question asked: 01 Aug, 20:14

question was seen: 129 times

last updated: 04 Aug, 07:56