Derived class constructor error

First of all, I am a beginner in C++ for 3 months now. These might be some stupid mistakes I made. My code still can't be compiled and it shows the following error:

1. In constructor 'Details::Details()':
[Error] no matching function for call to 'Property::Property()'

2. In function 'int main()':
[Note] synthesized method 'Details::Details()' first required here

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<iostream>
#include<string>
#include<conio.h>

using namespace std;
  class Property 
{
	private:
		string type;
		string name;
		string status;
		int no;
		
	public:
		
		//Setter(Method)
		void set_FieldName();
		void set_delprop();
		
		//Getter(Method)
		void get_FieldName();
		
		//Constructor
		Property(int o, string t, string n, string s)
		{
			no = o;
			type = t;
			name = n;
			status = s;
		}
};

//Derived Class
class Details : public Property
{
	private:
		Property e[10];
		Property temp[10];
		
	public:
		void AddProperty();
		void DeleteProperty();
		void ViewProperty();
		void SearchProperty();
	
};

int main()
{
	Property prop1( 1, "Residential","Terrace","Rent");
	Property prop2( 2, "Residential","Bungalow","Sale");
	Property prop3( 3, "Commercial","Factory","Sale");
	Property prop4( 4, "Commercial","Malls","Sale");
	Property prop5( 5, "Commercial","Farmlands","Rent");
	
	Details info;
	system ("cls");

	while(1){
		
		cout<<"\n\t\t\t\t\t1 : Add details of item"<< endl;
		cout<<"\t\t\t\t\t2 : Delete item details"<< endl;
		cout<<"\t\t\t\t\t3 : View all category of item"<< endl;
		cout<<"\t\t\t\t\t4 : View a property"<< endl;
		cout<<"\t\t\t\t\t0 : Exit" << endl;
		
		cout << endl << "\t\t\tEnter selection : ";
		cin>>selection;

	switch(selection)	{

			case 1 : info.AddProperty(); break;
			case 2 : info.DeleteProperty(); break;
			case 3 : info.ViewProperty(); break;
			case 4 : info.SearchProperty(); break;
			case 0 : system ("cls");exit(0);break;
			
			default: 
			cout <<"\nInvalid selection"<<endl;
			cout << "Press Enter to continue" <<endl;
			getch();
			break;
			
		}
		system("cls");
	}
	return 0;
	
}


It might be too long if I posted the whole code here but I think these are all that have problems with. Thank you for any help
If you create an array of Property then it will set the elements up using the constructor Property(). But this default constructor with no arguments ceases to exist once you have defined one with 4 arguments. You would have to define this additional constructor explicitly.

But I can't see what purpose Details would have in inheriting from Property. It seems to represent a collection of Property objects, not a specialised version of one.
Sorry but how do one define an additional constructor explicitly?

I tried removing the inheritance but it solves no problem and stays the same.
Just add ANOTHER blank constructor in your Property class:
Property(){}

This is needed when you define arrays like
Property e[10];
This compiles OK. Note that get_FieldName() should not return void:

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include <string>
//#include<conio.h>

using namespace std;

class Property {
	string type;
	string name;
	string status;
	int no {};

public:
	//Setter(Method)
	void set_FieldName() {}
	void set_delprop() {}

	//Getter(Method)
	void get_FieldName() {}

	//Constructor
	Property() {}
	Property(int o, const string& t, const string& n, const string& s) : no(o), type(t), name(n), status(s) {}
};

//Derived Class
class Details : public Property {
	Property e[10] {};
	Property temp[10] {};

public:
	void AddProperty() {}
	void DeleteProperty() {}
	void ViewProperty() {}
	void SearchProperty() {}

};

int main()
{
	Property prop1(1, "Residential", "Terrace", "Rent");
	Property prop2(2, "Residential", "Bungalow", "Sale");
	Property prop3(3, "Commercial", "Factory", "Sale");
	Property prop4(4, "Commercial", "Malls", "Sale");
	Property prop5(5, "Commercial", "Farmlands", "Rent");

	Details info;

	while (1) {
		cout << "\n\t\t\t\t\t1 : Add details of item" << endl;
		cout << "\t\t\t\t\t2 : Delete item details" << endl;
		cout << "\t\t\t\t\t3 : View all category of item" << endl;
		cout << "\t\t\t\t\t4 : View a property" << endl;
		cout << "\t\t\t\t\t0 : Exit" << endl;

		cout << endl << "\t\t\tEnter selection : ";

		int selection {};
		cin >> selection;

		switch (selection) {

			case 1: info.AddProperty(); break;
			case 2: info.DeleteProperty(); break;
			case 3: info.ViewProperty(); break;
			case 4: info.SearchProperty(); break;
			case 0: /*system("cls");*/ exit(0); break;

			default:
				cout << "\nInvalid selection" << endl;
				cout << "Press Enter to continue" << endl;
				//getch();
				break;

		}
		//system("cls");
	}
}

Thank you so much :D . It works perfectly now
Topic archived. No new replies allowed.