/*Ok first of all I just want to tell you that by this you're not doing my homework, because I am learning on my own right now.....This is just from a book that I am reading....and I decided to do something extra */
//Listing 10.1 Overloading class member functions
#include <iostream>
// Rectangle class declaration
class Rectangle
{
public:
// constructors
Rectangle(int width, int height);
~Rectangle(){}
// overloaded class function DrawShape
void DrawShape() const;
void DrawShape(int aWidth, int aHeight) const;
private:
int itsWidth;
int itsHeight;
};
//Constructor implementation
Rectangle::Rectangle(int width, int height)
{
itsWidth = width;
itsHeight = height;
}
// Overloaded DrawShape - takes no values
// Draws based on current class member values
void Rectangle:rawShape() const
{
DrawShape( itsWidth, itsHeight);
}
// overloaded DrawShape - takes two values
// draws shape based on the parameters
void Rectangle:rawShape(int width, int height) const
{
for (int i = 0; i<height; i++)
{
for (int j = 0; j< width; j++)
{
std::cout << "*";
}
std::cout << "\n";
}
}
// Driver program to demonstrate overloaded functions
int main()
{
// initialize a rectangle to 30,5
Rectangle theRect(30,5);
std::cout << "DrawShape(): \n";
theRect.DrawShape();
std::cout << "\nDrawShape(40,2): \n";
theRect.DrawShape(40,2);
return 0;
}
/* I want to creat a member method that takes in one pararemeter either width or height.... so then I can overload drawshape, and then getting the other missing argument by means of using enum, please help...........*/
PS THIS IS NOT MY HOMEWORK....using Sams Teach Yourself C++ in 21 days.