expected a type specifier error

When I try to assign a argument for constructor, error "expected a type specifier" pops out.
e.g runway run1(1),run2;

But I don't know the problem and how I can solve it, please help! Thanks.
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
#include<iostream>
#include<string>
using namespace std;
#define id1=1;id2=2;

class airport{
	private:
	public:

class runway{
		private:
			int no;
			char list[1000][3];
		public:

		runway(int id){
			no=id;
		}

		int showid(){
			return no; }

		void sort(){


		}


		void print(){
			
			
		}

	};
	runway run1,run2;
	
	void print(){
		run1.print();
		run2.print();
	}

	};

		
		class flight{
			private:string no,type,planned_time;
			public:
				flight(string no1,string type1,string planned_time1){
				no=no1;
				type=type1;
				planned_time=planned_time1;
			}

			string getno(){
				return no;}
		
	};


int main(){
	int n;
	string no,type,planned_time;
	cout<<"Please input the number of flights in the timetable:\n";
			cin>>n;
			cout<<"Please input the detail of the flights:\n";
			for(int i=0;i<n;i++){
				cin>>no>>type>>planned_time;
				flight setup(no,type,planned_time);
				


			}



	return 0;
}
runway run1,run2; You dont have a default constructor, so you cant do this. Your constructor takes one integer as parameter.

Add this to your class:

Runway() {}
Last edited on
TarikNeaj wrote:
runway run1,run2; You dont have a default constructor, so you cant do this. Your constructor takes one integer as parameter.

Add this to your class:

Runway() {}


Or if u want it to run as intended, pass an integer when you create an object.

1
2
runway run1(50);
runway run2(100);
Just because i assign arguments as this, the error pops up. Otherwise,it's fine,so that's the point confusing me.
runway run1(50);
Topic archived. No new replies allowed.