Showing posts with label passing object as argument. Show all posts
Showing posts with label passing object as argument. Show all posts

Monday, May 9, 2022

Can we pass class objects as function arguments? Explain with the help of an example.

 #include <iostream>

using namespace std;
class a
{
public:
    void show()
    {
        cout << "hello\n";
    }
    void show2(a A)
    {
        A.show();
    }
};
int main()
{
    a A,b;
    A.show2(b);

    return 0;
}
//first one is using method
#include <iostream>
using namespace std;
class a
{
public:
    void show()
    {
        cout << "hello\n";
    }
   
};
void show2(a A)
    {
        A.show();
    }
int main()
{
    a A;
   
    show2(A);

    return 0;
}
//this one is using function


HackCache ’26: A 48-Hour Online Hackathon Open to Every Student

  Hackathons are often associated with computer science students, experienced developers, and teams that already know exactly what they are...

Popular Posts