can someone run this code to see if it builds/works?

THANKS!!!!

#ifndef ENTRIES_HPP_
#define ENTRIES_HPP_

#include <iostream>
#include<string>
#include <sstream>
#include <fstream>

using namespace std;


class Entries {
public:
string song;

string author;

string genre;

string path;

Entries(song, author, genre, path);
~ Entries;
private:
void get_info(string song,string author, string genre,string path);
void print_info(Entries);


}
;

// @@@@@=============IMPLEMENTATION=============@@@@@

void Entries::get_info(string song, string author, string genre, string path,) {

//should i use this method and add paramters of an object and entry #?

//RETURN TO ThIS LATER


}



void Entries::print_info(Entries) {

}

#endif /* ENTRIES_HPP_ */

int main() {
Entries Ent1;// maximum of 5 entries for now!!!
Entries Ent2;
Entries Ent3;
Entries Ent4;
Entries Ent5;


string bl,bl1;//assign this to blank lines

ifstream inFile;
inFile.open("music.txt");

if (inFile.is_open()) {
inFile >> bl;//1
inFile >> bl1;//2
inFile >> Ent1.song;//3
inFile >> bl;//4
inFile >> Ent1.author;//5
inFile >> bl1;//6
inFile >> Ent1.genre;//7
inFile >> bl;//8
inFile >> Ent1.path;//9
inFile >> bl;//10
//Entry 2
inFile >> bl;//11
inFile >> bl1;//12
inFile >> Ent2.song;//13
inFile >> bl;//14
inFile >> Ent2.author;//15
inFile >> bl1;//16
inFile >> Ent2.genre;//17
inFile >> bl;//18
inFile >> Ent2.path;//19
inFile >> bl;//20
}

cout<<Ent1.song<<endl;


return 0;
}



HERE IS THE TXT FILE


Entry #1:

song:

author:

genre:

path:

Entry #2:

song:

author:

genre:

path:

Entry #3:

song:

author:

genre:

path:

Entry #4:

song:

author:

genre:

path:

Entry #5:

song:

author:

genre:

path:


http://ideone.com/ - run it yourself. Though you'll have to make some changes (change file io to console io, join the two files into one). By the way, you don't seem to be including the header in your cpp. Unless this is all one file. In that case, why would you have header guards?
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
#include <iostream>
#include<string>
#include <sstream>
#include <fstream>

using namespace std;


class Entries 
	{
		public:
				string song;
				string author;
				string genre;
				string path;
				Entries() {}
				Entries(song, author, genre, path) : song( song ) , author( author ) , genre ( genre ) , path( path ) { } 
				~	Entries();
private:
				void get_info(string song,string author, string genre,string path);
				void print_info(const Entries entries );


}
;

// @@@@@=============IMPLEMENTATION=============@@@@@

void Entries::get_info(string song, string author, string genre, string path,) 
	{

//should i use this method and add paramters of an object and entry #?

//RETURN TO ThIS LATER


}



void Entries::print_info(const Entries entries ) 
	{

   }

#endif /* ENTRIES_HPP_ */

int main() 
	{
				Entries Ent1;// maximum of 5 entries for now!!!
				Entries Ent2;	

				string bl,bl1;//assign this to blank lines

				ifstream inFile;
				inFile.open("music.txt");

				if (inFile.is_open()) 
					{
							inFile >> bl;//1
							inFile >> bl1;//2
							inFile >> Ent1.song;//3
							inFile >> bl;//4
							inFile >> Ent1.author;//5
							inFile >> bl1;//6
							inFile >> Ent1.genre;//7
							inFile >> bl;//8
							inFile >> Ent1.path;//9
							inFile >> bl;//10
							//Entry 2
							inFile >> bl;//11
							inFile >> bl1;//12
							inFile >> Ent2.song;//13
							inFile >> bl;//14
							inFile >> Ent2.author;//15
							inFile >> bl1;//16
							inFile >> Ent2.genre;//17
							inFile >> bl;//18
							inFile >> Ent2.path;//19
							inFile >> bl;//20
				}

				cout<<Ent1.song<<endl;


return 0;
}
i am geting errors

prog.cpp:3:1: error: unterminated #ifndef
prog.cpp:27: error: expected `)' before ‘,’ token
prog.cpp:39: error: expected identifier before ‘)’ token
prog.cpp:39: error: prototype for ‘void Entries::get_info(std::string, std::string, std::string, std::string, int)’ does not match any in class ‘Entries’
prog.cpp:30: error: candidate is: void Entries::get_info(std::string, std::string, std::string, std::string)



any ideas?
Sorry, but what should the code do?
post the track so we can make suggestions.

However, the code you posted has some error like the type of parameters in Constructor of Entries (must be (string,string,string,string) and not the members themself. Then you should declare 'public' and not 'private' the func 'get_info' and 'print_info', since you should use theme in the main, ecc.
For the main block that you posted, you can use the 'struct' insted of 'class' for Entries object.
you can use:
struct Entries{
string song;
string author;
string genre;
string path;
}

and the related function to manage this object.
Last edited on
please include
1
2
#ifndef ENTRIES_HPP_
#define ENTRIES_HPP_ 


at the top of the code .
Topic archived. No new replies allowed.