Hi there,
I'm trying to create a demonstration of a modified copy constructor. As can be seen from the code below, I've created a class called Track and defined a copy constructor such that a new object of type "Track" can be defined with the same track artist and album name, but increment the track number by 1. It compiles fine, but when I try to run it in MS VC++, I get two link errors:
"error LNK2001: unresolved external symbol", and
"fatal error LNK1120: 1 unresolved externals".
If anybody can tell me what I'm doing wrong, it would be much appreciated!
#include<iostream>
#include<string>
using namespace std;
class Track
{
public:
string artist;
string album;
int trackNumber;
Track(string artist, string album, int trackNumber);
Track(const Track &sourceTrack);
virtual void display();
};
Track::Track(const Track &sourceTrack): //Copy constructor
artist(sourceTrack.artist),
album(sourceTrack.album),
trackNumber(sourceTrack.trackNumber + 1)
{
}
void Track::display()
{
cout << "Artist: " << artist << endl
<< "Album: " << album << endl
<< "Track Number: " << trackNumber << endl;
}
int main()
{
Track a = Track("TOOL","Third Eye",13);
Track b(a);
a.display();
b.display(); //Should display a new object "b" of type Track
//with the same artist and title as object "a",
//except increment trackNumber by 1
system("Pause");
return EXIT_SUCCESS;
}