#include <iostream>
#include <cmath>
using namespace std;

class Rectangle {
public:
int width, height;
Rectangle();
~Rectangle();
double r_area();
double r_perimeter();
};


Rectangle::Rectangle()
{
width = 1;
height = 1;
}
Rectangle::~Rectangle()
{
}

double Rectangle::r_area()
{
return (width * height);
}

double Rectangle::r_perimeter()
{
return (2*width + 2* height);
}

int main ()
{
cout<< "Defaults:" << endl;
Rectangle r;
cout << "Rectangle area = " << r.r_area() << " Perimeter = " << r.r_perimeter() << endl;
cout << "Rectangle: Please enter length and width: ";
cin >> r.height, r.width ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<ERROR
cout << "Rectangle area = " << r.r_area() << " Perimeter = " << r.r_perimeter() << endl;

system("pause");
return 0;
}

I am trying to take a user input for width and height but I have a problem in the Cin;
Any ideas?
thanks :)

Look into chaining the input operator.You can't do it with a comma.

As caut mentioned, you can't read in with a comma. In addition, you could always make the class variables private and use a member function to set them rather than allowing main() direct access to them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.