I am new to c++ but have been using java for a while now. I am using Microsoft Visual c++ and when I try to build it I get the following error:

Linking...
Airline Project.obj : error LNK2019: unresolved external symbol "public: __thiscall FlightManager::FlightManager(void)" (??0FlightManager@@QAE@XZ) referenced in function _wmain
F:\Documents\Assignments\CA212\Airline Project\Debug\Airline Project.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://f:\Documents\Assignments\CA212\Airline Project\Airline Project\Debug\BuildLog.htm"

Here is where I think the relevant code is:

#include "stdafx.h"


#include <iostream>
using namespace std;

#include "FlightManager.cpp"



int _tmain(int argc, _TCHAR* argv[])
{

	cout << "Welcome to Airline Manager v1.0" << endl << endl;

	FlightManager fMan;

which is Airline Project.cpp

and this:

#include "stdafx.h"

#include <iostream>
using namespace std;

#include <fstream>
using namespace std;

#include <cstdlib>
using namespace std;


#include "Flight.cpp"


class FlightManager
{
	public :
		FlightManager();

which is in FlightManager.cpp

I have tried a few different solutions that I found but will admit that c++ is getting the better of me

Recommended Answers

All 7 Replies

The error is saying that you declared the FlightManager constructor ( FlightManager(); ) but never defined it. You must give a body to any functions before you can call them.

Why didn't you put the end braces?

int _tmain(int argc, _TCHAR* argv[])
{

	cout << "Welcome to Airline Manager v1.0" << endl << endl;

	FlightManager fMan;
[B]}[/B]
class FlightManager
{
	public :
		FlightManager();
[B]}[/B]

The error is saying that you declared the FlightManager constructor ( FlightManager(); ) but never defined it. You must give a body to any functions before you can call them.

Try this:

#include "stdafx.h"

#include <iostream>
#include <fstream>
#include <cstdlib>

#include "Flight.cpp"

using namespace std;

class FlightManager
{
	public :
		FlightManager() [B]{}[/B];

PS, you only need to state "using namespace std;" once.

I didnt put end braces as there was more code. I only posted what I thought was relevant.


How would I declare the FlightManager without using any parameters and not setting anything. I dont want the constructor to do anything except create a FlightManager so I can use its methods.

I dont want the constructor to do anything except create a FlightManager so I can use its methods.

Just don't define the constructor explicitly (in that case the compiler will use the class' standard constructor to create an instance of the object) :)

Edit:: this means that you just have to strip the line FlightManager(); out of your code ...

Thanks. I first changed it to

FlightManager(){};

then read the post about not needing it at all. I forgot that what I wanted was what was default anyways.

I feel pretty stupid about how much time I spent on it. Java's error codes are so much more intuative.

Thanks

>Java's error codes are so much more intuative.
Three words: null pointer exception. ;) Anywhoo, you don't have the right to complain about non-intuitive error messages until you've had the pleasure of deciphering about twenty of these guys all at once:

error C2664: 'class std::_Tree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>,struct std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::_Kfn,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::iterator __thiscall std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::insert(const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &)' : cannot convert parameter 1 from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &' Reason: cannot convert from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>' No constructor could take the source type, or constructor overload resolution was ambiguous

Three cheers for not having to use Visual Studio 6 anymore. Woohoo! ;)

commented: LOL:P +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.