1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl createVideoList(class std::basic_ifstream<char,struct std::char_traits<char> > &,class Video &)" (?createVideoList@@YAXAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAVVideo@@@Z) referenced in function _main
1>c:\users\******\documents\visual studio 2010\Projects\Programming Assignment 4\Debug\Programming Assignment 4.exe : fatal error LNK1120: 1 unresolved externals
I'm working on a Programming Assignment and I'm getting this Link Error 2019 when trying to compile. It references the createVideoList, and these are the lines of my code related to that:
#include <iostream>
#include <fstream>
#include <string>
#include "Video.h"
using namespace std;
void createVideoList(ifstream& infile, Video videoArray);
int main()
{
...
createVideoList(inputfile, videoArray[50]);
}
void createVideoList(ifstream& ifile, Video videoArray[50])
{
string title;
string star1;
string star2;
string producer;
string director;
string productionCo;
int inStock;
int count = 0;
Video newVideo;
getline(ifile, title);
while (ifile)
{
getline(ifile, star1);
getline(ifile, star2);
getline(ifile, producer);
getline(ifile, director);
getline(ifile, productionCo);
ifile >> inStock;
newVideo.setVideoInfo(title, star1, star2, producer,
director, productionCo, inStock);
videoArray[count] = newVideo;
getline(ifile, title);
}
}
Not sure exactly what code I need to post on here to help you guys out, since I'm not even sure of what the error is saying in the first place. Thanks in advance!
void createVideoList(ifstream& infile, Video& videoArray);
it should be
void createVideoList(ifstream& infile, Video* videoArray);
These two are different declarations. In first one, second parameter is reference to Video variable and second one is pointer, which may be an array, what it is in your case.
Also if you want to pass array as an argument to function, you should call it this way:
createVideoList(inputfile, videoArray[]);
or
createVideoList(inputfile, videoArray);
Because when you are doing that:
createVideoList(inputfile, videoArray[50]);
you are just passing 50-th element of array.