why doesnt this code work

These are the errors I get.

Error C4700 uninitialized local variable 'f'
no instance of constructor "project::project" matches the argument list
no instance of constructor "project::project" matches the argument list
no instance of constructor "project::project" matches the argument list
Error C4700 uninitialized local variable 'h' used
Error C4700 uninitialized local variable 'e' used
Error C4700 uninitialized local variable 'd' used
Error C4700 uninitialized local variable 'c' used
Error C4700 uninitialized local variable 'b' used Project8
Error C4700 uninitialized local variable 'a' used Project8


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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  #include<iostream>
using namespace std;

class project
{

private:
	float base, base2, height;
	float diagonal, diagonal2;
	float base3, aldtude;
public:
	void trapezium() {

		float areaoftrapezium;
		areaoftrapezium = 0.5*(base + base2)*height;
		cout << "the area of trapezium is:" << areaoftrapezium;
	}
	void rhombus() {

		float areaofrhombus;
		areaofrhombus = 0.5*diagonal*diagonal2;
		cout << "the  area of rhombus is:" << areaofrhombus;
	}
	void Parallelogram() {

		float areaofParallelogram;
		areaofParallelogram = base3*aldtude;
		cout << "the  area of Parallelogram is:" << areaofParallelogram;
	}

	project(int a, int b, int c, int d, int e, int f, int h) {
		base = a;
		base2 = b;
		height = c;
		diagonal = d;
		diagonal2 = e;
		base3 = f;
		aldtude = h;
	}


	float getbase() {
		return base;
	}
	float getbase2() {
		return base2;
	}
	float getheight() {
		return height;
	}
	float getdiagonal() {
		return diagonal;

	}
	float getdiagonal2() {
		return diagonal2;
	}
	float getbase3() {
		return base3;
	}
	float getaldtude() {
		return aldtude;
	}
};

int main()

{
	int a, int b, int c, int d, int e, int f, int h;
	int option = 0;


	cout << "write 1 for areaoftrapezium and 2 for areaofrhombus and 3 for areaofParallelogram " << endl;
	cin >> option;
	switch (option) {
	case  '1':
		cout << "Enter the value for two bases & height of the trapezium: " << endl;
		cin >> a;
		cin >> b;
		cin >> c;
		project obj(a, b, c);
		 obj.trapezium();
		 break;

	case  '2':
		cout << "Enter diagonals of the given rhombus:" << endl;
		cin >> d;
		cin >> e;
		project obj(d, e);

		obj.rhombus();

	case  '3':
		cout << "Enter base and altitude of the given Parallelogram:  " << endl;
		cin >> f;
		cin >> h;
		obj.Parallelogram();
		project obj(f, h);

		break;

	}

	system("pause");
	return 0;

}


You only created a constructor with 7 parameters, so all your objects must use this constructor (you need 7 parameters in all instances). If you want to use a constructor with a different number of parameters you'll need to create a constructor with that number of parameters.





ok i fix it like this but ihave this error i dont know what wrong

Error C2065 'd': undeclared identifier
Error (active) no instance of constructor "project::project" matches the argument list
Error C2062 type 'int' unexpected Project8
Error C2065 'b': undeclared identifier
Error C2065 'c': undeclared identifier
Error C2065 'e': undeclared identifier
Error C2065 'f': undeclared identifier
Error C2065 'h': undeclared identifier
Error C2065 'b': undeclared identifier
Error C2065 'c': undeclared identifier
Error C2065 'e': undeclared identifier
Error C2065 'f': undeclared identifier
Error C2065 'h': undeclared identifier









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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include<iostream>
using namespace std;

class project
{

private:
	float base, base2, height;
	float diagonal, diagonal2;
	float base3, aldtude;
public:
	void trapezium() {

		float areaoftrapezium;
		areaoftrapezium = 0.5*(base + base2)*height;
		cout << "the area of trapezium is:" << areaoftrapezium;
	}
	void rhombus() {

		float areaofrhombus;
		areaofrhombus = 0.5*diagonal*diagonal2;
		cout << "the  area of rhombus is:" << areaofrhombus;
	}
	void Parallelogram() {

		float areaofParallelogram;
		areaofParallelogram = base3*aldtude;
		cout << "the  area of Parallelogram is:" << areaofParallelogram;
	}

	project(int a, int b, int c, int d, int e, int f, int h) {
		base = a;
		base2 = b;
		height = c;
		diagonal = d;
		diagonal2 = e;
		base3 = f;
		aldtude = h;
	}


	float getbase() {
		return base;
	}
	float getbase2() {
		return base2;
	}
	float getheight() {
		return height;
	}
	float getdiagonal() {
		return diagonal;

	}
	float getdiagonal2() {
		return diagonal2;
	}
	float getbase3() {
		return base3;
	}
	float getaldtude() {
		return aldtude;
	}
};

int main()

{
	int a, int b, int c, int d, int e, int f, int h;
	int option = 0;

	project obj(a, b, c,e,f,h);

	cout << "write 1 for areaoftrapezium and 2 for areaofrhombus and 3 for areaofParallelogram " << endl;
	cin >> option;
	switch (option) {
	case  '1':
		cout << "Enter the value for two bases & height of the trapezium: " << endl;
		cin >> a;
		cin >> b;
		cin >> c;
		 obj.trapezium();
		 break;

	case  '2':
		cout << "Enter diagonals of the given rhombus:" << endl;
		cin >> d;
		cin >> e;

		obj.rhombus();

	case  '3':
		cout << "Enter base and altitude of the given Parallelogram:  " << endl;
		cin >> f;
		cin >> h;
		obj.Parallelogram();

		break;

	}

	system("pause");
	return 0;

}

Bad variable declaration in line 69. Try

int a, b, c, d, e, f, h;
thankyou i try it and the proplem gone but idont know where the proplem with this erreors

Error C2661 'project::project': no overloaded function takes 6 arguments 73
Error (active)no instance of constructor "project::project" matches the argument list 73

the errors in this line
project obj(a, b, c,e,f,h);


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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include<iostream>
using namespace std;

class project
{

private:
	float base, base2, height;
	float diagonal, diagonal2;
	float base3, aldtude;
public:
	void trapezium() {

		float areaoftrapezium;
		areaoftrapezium = 0.5*(base + base2)*height;
		cout << "the area of trapezium is:" << areaoftrapezium;
	}
	void rhombus() {

		float areaofrhombus;
		areaofrhombus = 0.5*diagonal*diagonal2;
		cout << "the  area of rhombus is:" << areaofrhombus;
	}
	void Parallelogram() {

		float areaofParallelogram;
		areaofParallelogram = base3*aldtude;
		cout << "the  area of Parallelogram is:" << areaofParallelogram;
	}

	project(int a, int b, int c, int d, int e, int f, int h) {
		base = a;
		base2 = b;
		height = c;
		diagonal = d;
		diagonal2 = e;
		base3 = f;
		aldtude = h;
	}


	float getbase() {
		return base;
	}
	float getbase2() {
		return base2;
	}
	float getheight() {
		return height;
	}
	float getdiagonal() {
		return diagonal;

	}
	float getdiagonal2() {
		return diagonal2;
	}
	float getbase3() {
		return base3;
	}
	float getaldtude() {
		return aldtude;
	}
};

int main()

{
	int a, b, c, d, e, f, h;

	int option = 0;

	project obj(a, b, c,e,f,h);

	cout << "write 1 for areaoftrapezium and 2 for areaofrhombus and 3 for areaofParallelogram " << endl;
	cin >> option;
	switch (option) {
	case  '1':
		cout << "Enter the value for two bases & height of the trapezium: " << endl;
		cin >> a;
		cin >> b;
		cin >> c;
		 obj.trapezium();
		 break;

	case  '2':
		cout << "Enter diagonals of the given rhombus:" << endl;
		cin >> d;
		cin >> e;

		obj.rhombus();

	case  '3':
		cout << "Enter base and altitude of the given Parallelogram:  " << endl;
		cin >> f;
		cin >> h;
		obj.Parallelogram();

		break;

	}

	system("pause");
	return 0;

}

Count the number of parameters in your constructor. How many does it have, hint it's not 6.

Also in that constructor call those variables should be initialized before you call the constructor.

Last edited on
thank you very much for your help

for initialized thing idont kknow what you mean you know im sill new to c++
can you please explain it for me
Topic archived. No new replies allowed.