Class Problem (no appropriate default constructor available)

This is my homework but i have problem with constructor.
my error: error C2512: 'Rectangle' : no appropriate default constructor available
can you help me?
Last edited on
There is no a call of the default constructor in this code. Show the code where the error occured.
But in any case the error message is clear enough. You are creating an object of class Rectangle specifying the default constructor though the last was not defined.
i am calling default constructor in here and error is in "Rectangle objectOne;" line.
how can i fix it?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include "Rectangle.h"


using namespace std;

int main ()
{

	int recNum;
	Rectangle objectOne();
	Rectangle objectTwo (3, 4);
	Rectangle objectThree (-1, 2);
	cout<<"Welcome to rectangle information sheet"<<endl;
	cout<<"You have 3 rectangles"<<endl;
	cout<<"Please enter rectangle number"<<endl;
	cin>>recNum;

		if (recNum == 1)
		{
			cout<<"Your rectangle 1 information:"<<endl;
            cout<<"Area: "<<objectOne.findArea()<<endl;
			cout<<"Perimeter"<<objectOne.findPerimeter()<<endl;
		}

		else if (recNum ==2 )
		{
			cout<<"Your rectangle 2 information:"<<endl;
cout<<"Area: "<<objectTwo.findArea()<<endl;
			cout<<"Perimeter"<<objectTwo.findPerimeter()<<endl;
		}
		else if (recNum == 3 )
		{
			cout<<"Your rectangle 3 information:"<<endl;
            cout<<"Area: "<<objectThree.findArea()<<endl;
			cout<<"Perimeter"<<objectThree.findPerimeter()<<endl;
		}
		else
		cout<<"Please enter a number 1 to 3"<<endl;
}
}
Last edited on
By the way this statement

Rectangle objectOne();

is a declaration of a function that returns an object of type Rectangle.
Topic archived. No new replies allowed.