Question 1
#include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z)
{ return (x + y + z); }
int main()
{
cout << fun(10);
return 0;
}
Question 2
#includeusing namespace std; void square (int *x) { *x = (*x)++ * (*x); } void square (int *x, int *y) { *x = (*x) * --(*y); } int main ( ) { int number = 30; square(&number, &number); cout << number; return 0; }
Question 3
Question 4
int fun(int x, int y); void fun(int x, int y);2) Functions that differ only by static keyword in return type
int fun(int x, int y); static int fun(int x, int y);3)Parameter declarations that differ only in a pointer * versus an array []
int fun(int *ptr, int n); int fun(int ptr[], int n);4) Two parameter declarations that differ only in their default arguments
int fun( int x, int y); int fun( int x, int y = 10);
Question 5
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y) { return (x+y); }
Question 6
include<iostream>
using namespace std;
class Test
{
protected:
int x;
public:
Test (int i):x(i) { }
void fun() const { cout << "fun() const " << endl; }
void fun() { cout << "fun() " << endl; }
};
int main()
{
Test t1 (10);
const Test t2 (20);
t1.fun();
t2.fun();
return 0;
}
fun()
fun() const
fun() const
fun() const
fun()
fun()
There are 6 questions to complete.