I have watch few tutorials about classes but all of them show the functions that uses all of its parameters (such as this).
This is an example I took from cplusplus.com
#include "stdafx.h"
#include <iostream>
using namespace std;
class Rectangle
{
double width, height;
public:
void setValues ( double, double );
double area ()
{
return width * height;
}
};
void Rectangle::setValues ( double x, double y )
{
width = x;
height = y;
}
int main ()
{
Rectangle rect;
double x;
double y;
cout << "Enter the height: ";
cin >> x;
cout << "Enter the width: ";
cin >> y;
rect.setValues(x, y);
cout << "The area of your rectangle is " << rect.area() << "." << endl;
return 0;
}
How can I create a class with multiple parameters and multiple type (int, float) that can be partially call later by different function?
Some shape require different parameters such as width, height, radius, and radians. But none requires all at the same time. For instance, a rectangle function will use width and height. But to calculate a circle, it will only require radius parameter.
This is a mere example as it could only save me a few repetitive line in each functions. But I have plans to try it in more complex problems.
I'm new to programming. Forgive me for asking this childish question :-(