Unresolved errors in main: "type name is not allowed"

As the title suggests, I am having errors: on line 59, 63 and 65. They are "identifier is undefined" (lines 63 & 65) and line 59 is "type name is not allowed". My goal is to have the output look and behave like this:

https://imgur.com/a/crTvbS3

Any help would be appreciated.

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
#include<iostream>
#include<iomanip> 
#include <string> 

using namespace std;

class Song {
private:
	string title;
	string artist;
public:
	Song();
	Song(string title, string artist); //parameterized constructor
	~Song();
	void setTitle(string title); //function declaration
	void setArtist(string artist);
	void displaySong();

};

Song::Song()
{
	string title = "";
	string artist = "";
}

Song::Song(string title, string artist)
{
	string title = "All of Me";
	string artist = "Billie Holliday";

}
	
Song::~Song() {}

void Song::setTitle(string tit)
{
	title = tit;
}

void Song::setArtist(string art)
{
	artist = art;
}
	
void Song::displaySong()
{
	cout << "Here is your song: " << endl;
	cout << "Title: " << title << endl;
	cout << "Artist: " << artist << endl;
}

int main()
{
	Song yourSong, anotherSong;
	
	yourSong.displaySong();
	
	anotherSong.Song(string title, string artist);

	cout << "Enter information about your song: " << endl;
	cout << "Title: ";
	cin >> setTitle << endl;
	cout << "Artist: ";
	cin >> setArtist << endl;

	cout << "Here is your song: " << endl;
	cout << "Title: " << setTitle << endl;
	cout << "Artist: " << setArtist << endl;

	system("PAUSE");
	return 0;
}
Last edited on
To give you an idea. I commented some things out so you can compare.
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
#include<iostream>
#include<iomanip> 
#include <string> 

using namespace std;

class Song {
	private:
		string title;
		string artist;
	public:
		Song();
		Song(string /*title*/tit, string /*artist*/art); //parameterized constructor
		~Song();
		void setTitle(string /*title*/tit); //function declaration
		void setArtist(string /*artist*/art);
		void displaySong();
		string getTitle() const;
		string getArtist() const;

};

Song::Song()
{
	string title = "";
	string artist = "";
}

Song::Song(string tit, string art)
{
	/*string*/ title = /*"All of Me"*/ tit;
	/*string*/ artist = /*"Billie Holliday"*/ art;

}

Song::~Song() {}

void Song::setTitle(string tit)
{
	title = tit;
}

void Song::setArtist(string art)
{
	artist = art;
}

void Song::displaySong()
{
	//cout << "Here is your song: " << endl;
	cout << "Title: " << title << endl;
	cout << "Artist: " << artist << endl;
}

string Song::getTitle() const
{
	return title;
}

string Song::getArtist() const
{
	return artist;
}


int main()
{
	Song yourSong, anotherSong("All of me", "Billie Holiday");

	cout << "Here is your song: " << endl;
	yourSong.displaySong();

	//anotherSong.Song(string title, string artist);
	cout << "Another song: " << endl;
	anotherSong.displaySong();

	cout << "Enter information about your song: " << endl;
	cout << "Title: ";
	string title = "";
	/*cin >> setTitle << endl;*/
	getline(cin, title);
	yourSong.setTitle(title);
	cout << "Artist: ";
	string artist = "";
	/*cin >> setArtist << endl;*/
	getline(cin, artist);
	yourSong.setArtist(artist);

	cout << "Here is your song: " << endl;
	cout << "Title: " << yourSong.getTitle()/*setTitle*/ << endl;
	cout << "Artist: " << yourSong.getArtist() /*setArtist*/<< endl;

	system("PAUSE");
	return 0;
}
Last edited on
thank you - this resolved all my errors. And in the process I learned about getters. Thanks again.
Topic archived. No new replies allowed.