Multiple class inheration problem

Hello everyone! I'm trying to make a program with multiple class inheration, but I get some really weird errors that I can't figure out how to solve. The program saves the location that is entered. The first class holds the continent and the country,the second holds the county and the city, and the third and last one holds the street and the streetnumber.

world_location.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
#ifndef __WORLD_LOCATION_H__
#define __WORLD_LOCATION_H__

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

class world_location
{
	string continent;
	string country;
public:
	//default constructor
	world_location()
	{
		continent = "unknown";
		country = "unknown";
	}
	//constructor
	world_location(string continent_, string country_)
	{
		continent = continent_;
		country = country_;
	}
	//shows the continent and the country
	void show_world_location()
	{
		cout << "Continent: " << continent << endl << "Country: " << country << endl;
	}
};
#endif 


country_location.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
#ifndef __COUNTRY_LOCATION_H__
#define __COUNTRY_LOCATION_H__

class country_location : public world_location
{
	string county;
	string city;
public:
	//default constructor
	country_location()
	{
		county = "unknown";
		city = "unknown";
	}
	//constructor
	country_location(string continent_, string country_, string county_, string city_)
		: world_location(continent_, country_)
	{
		county = county_;
		city = city_;
	}
	//displays the continent, country, county and the city
	void show_country_location()
	{
		show_world_location();
		cout << "County: " << county << endl << "City: " << city << endl;
	}
};
#endif 


city_location.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
#ifndef __CITY_LOCATION_X__
#define __CITY_LOCATION_X__

class city_location : public country_location
{
	string street;
	string streetnumber;
public:
	//default constructor
	city_location()
	{
		street = "unknown";
		streetnumber = "unknown";
	}
	//constructor
	city_location(string continent_, string country_, string county_, string city_,
	 string street_, string streetnumber_) : country_location(continent_, country_, county_, city_)
	{
		street = street_;
		streetnumber = streetnumber_;
	}
	//displays all the locations
	void show_all()
	{
		show_world_location();
		show_country_location();
		cout << "Street: " << street << endl << "Streetnumber: " << streetnumber << endl;
	}
}
#endif 


main()
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

#include "world_location.h"
#include "country_location.h"
#include "city_location.h"

int main()
{
	city_location ob1("Contient here", "Country here", "County here", "City here", "Street here", "Streetnumber here");
	ob1.show_all();
	return 0;
}


I'm using visual studio, and the errors are:
1>------ Build started: Project: Hello world, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\demo\documents\visual studio 2010\projects\hello world\hello world\main.cpp(8): error C2628: 'city_location' followed by 'int' is illegal (did you forget a ';'?)
1>c:\users\demo\documents\visual studio 2010\projects\hello world\hello world\main.cpp(9): error C3874: return type of 'main' should be 'int' instead of 'city_location'
1>c:\users\demo\documents\visual studio 2010\projects\hello world\hello world\main.cpp(12): error C2664: 'city_location::city_location(const city_location &)' : cannot convert parameter 1 from 'int' to 'const city_location &'
1> Reason: cannot convert from 'int' to 'const city_location'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It got to be something with city_location.h, since if I remove it and just use world_location.h and country_location.h, everything works fine. I also think there is something wrong with city_location.h's contructor. All help would be greatly appreciated!
Took a quick look and saw one important thing: your class called city_location doesn´t have semicolon near the #endif.
That fixed it! I feel really stupid now for not noticing that :|. Thank you very much!
Last edited on
No problem. You´re welcome.
Topic archived. No new replies allowed.