# include <iostream >
using namespace std;
class A
private :
int a = 10;
char ch= 'b';
public :
friend class B ;
};
class B
public:
void display (A ob )
cout << ob.a<<endl;
cout << ob.ch<<endl;
};
int main()
A ob1;
B ob2;
ob2.display(ob1);}
# include <iostream>
using namespace std;
class test
private:
int data1;
int data2;
public:
test (){}
test(int x,int y)
data1=x;
data2=y;
void display();
friend void multiply(test m);
};
void test::display()
cout<<"data 1 is "<<data1<<endl;
cout<<"data 2 is "<< data2<<endl;
}
void multiply (test m)
int datao;
datao=m.data1*m.data2;
cout<<"multiplicaation"<<datao;
int main ()
test obj(100,200);
obj.display();
multiply(obj);
#include <iostream>
using namespace std;
void sum(int a ,int b)
int c=a+b;
cout<<c<<endl;
void sum(int a ,int b,int z)
int c=a+b+z;
cout<<c<<endl;
}
int main ()
sum(10,20);
sum(30,10,10);
#include <iostream>
using namespace std;
inline void display()
cout<<"hellow world";
int main ()
display();
#include <iostream>
using namespace std ;
class example
public:
int data ;
example (){}
example (int x)
{
data =x;
void display ()
cout<<"data is "<< data <<endl;
};
int main ()
example obj(50);
example obj2 (obj);
obj.display();
obj2.display();
#include <iostream>
using namespace std;
class A {
public:
int a,b;
A(){}
A(int x,int y )
a=x;
b=y;
}
A operator +(A ob)
{ A temp;
temp.a= a+ob.a;
temp.b=b+ob.b;
return temp;
};
int main ()
A ob1(30,40);
A ob2(30,100);
A ob3= ob1+ob2;
cout << ob3.a<<endl<<ob3.b;
# include <iostream>
using namespace std;
namespace a
int x=10;
int show ()
return 5;
}
namespace b
int x=30;
string show ()
return "inside a";
namespace student{
class st
{public:
void display()
cout<<"student::st::display()\n";
};
int main ()
{//access value function of A
cout<<a::show()<<endl;
cout << b::show()<< endl;
cout<<b::x<<endl;
student::st ob;
ob.display();
return 0;
#include <iostream>
#include <algorithm>
using namespace std;
void show (int a[])
{for (int i =0;i<10;i++)
cout <<a[i]<<" ";
int main (){
int a [10]={2,6,5,20,42,0,3,4,8};
cout << "the array before sorting ";
show (a);
sort(a,a+10);
cout <<"the array after sorting";
show (a);
return 0;
#include <iostream>
#include <algorithm>
using namespace std;
void show (int a[])
{for (int i =0;i<10;i++)
cout <<a[i]<<" ";
int main (){
int a [10]={2,6,5,20,42,0,3,4,8};
cout << "the array before sorting ";
show (a);
sort(a,a+10);
cout <<"the array after sorting";
show (a);
return 0;
#include <iostream>
#include <vector>
using namespace std ;
int main()
vector <int> A;//vector keyword, data type,vector name
A.push_back(40);
A.push_back(30);
A.push_back(35);
A.push_back(4);
A.push_back(50);
cout <<"the second index is";
cout<< A[2]<< endl;
for(int i =0;i<A.size();i++)
cout<<A[i]<<" " <<endl;