CLASS SONG ERROR
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 111 112 113 114 115 116 117 118 119 120
|
/****************
Program #1
class that models an electronic music track
****************/
//Song Class
#ifndef SONG_CLASS
#define SONG_CLASS
using namespace std;
class Song
{
private:
string title; //dynamic allocation
string album;
string genre;
string artist;
double durationn;
public:
Song();
void setTitle(string t);
void setDuration(double d);
void setAlbumName(string a);
void setGenre(string g);
void setArtist(string a);
string getTitle();
string getAlbum()const;
string getGenre()const;
string getArtist()const;
double getDuration)(); //accessor
};
//constructor
Song::Song() //constructor
{
title="";
album="";
genre="";
artist="";
duration=0;
}
//accessor for name
string Song::getTitle()
{
return title;
}
//mutator
void Song::setTitle(string t)
{
title=t;
}
//accessor for name
string Song::getAlbum()
{
return album;
}
//mutator
void Song::setAlbumName(string a)
{
album=a;
}
//accessor for name
string Song::getGenre()
{
return genre;
}
//mutator
void Song::setGenre(string g)
{
genre=g;
}
//accessor for name
string Song::getArtist()
{
return artist;
}
//mutator
void Song::setArtist(string s)
{
artist=s;
}
void Song::setDuration(double d)
{
duration=d;
}
double Song::getDuration()
{
return duration;
}
#endif // SONG_CLASS
//FOR THE TEST.CPP FILE
//file test.cpp
#include <iostream>
#include <fstream>
#include <string>
#include "song.h"
using namespace std;
int main()
{
return 0;
}
//HOW CAN I DISPLAY THE OUTPUT?? -------->
//MY PROFESSOR WANTS ME TO WRITE TO A FILE CALL SONG.OUT
//SOMEONE PLEASE HELPPPPPPPPPPP!
|
1 2 3 4 5
|
ofstream ofile("song.out");
ofile << song.title << endl;
ofile << song.album << endl;
// etc...
ofile.close();
|
That should give you a hint for writing the file.
~psault
Topic archived. No new replies allowed.