Showing posts from February, 2023Show all

3) Write a C++ program on this pointer.

#include <iostream> #include <cstring> using namespace std; class Person {     char name[20];     int age;     public:     Person(char *s, float b)     {         strcpy(name,s);         age=b;     }     Person &  greater(Person &y)     {         if(y.age>age)         return y;         else     …

Read more

6) Write a C++ program that implements operators << , >> and * (scalar vector ) using operator overloading.

#include <iostream> using namespace std; const int N=3; class Vector {     int V[N];     public:     Vector()     {         for(int i=0;i<N;i++)         V[i]=0;     }     Vector(int *y)     {         for(int i=0;i<N;i++)         V[i]=y[i];     }    friend Vector operator*(int a, Vector b );     friend Ve…

Read more