I am struggling with
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl Book::Book(void)" (??0Book@@QEAA@XZ) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl Book::update(class Order)" (?update@Book@@QEAAXVOrder@@@Z) referenced in function main
From what I have read, it usually is because of missing selectors, but I can't see myself missing anything. Also, no static variables, parameters seem correct, ... going through the issue list below didn't help figure out the issue.
https://msdn.microsoft.com/en-us/library/799kze2z.aspx
#include <QCoreApplication>
#include <order.h>
#include <book.h>
#include <iostream>
#include <vector>
std::vector<Order> md_orders;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Order order;
order.setIsBid( true );
order.setSize( 500 );
order.setPrice( 10.00 );
double price = order.getPrice();
Book book;
book.update( order );
std::cout << price;
return a.exec();
}
book.h
#ifndef BOOK_H
#define BOOK_H
//#include <order.h>
#include <vector>
class Book
{
public:
Book();
Order getBest( double, bool );
void update( Order );
double getBestPrice( bool );
private:
std::vector<Order> _orders;
};
#endif // BOOK_H
book.cpp
#include "book.h"
#include <limits>
//#include <order.h>
#include <iostream>
int imax = std::numeric_limits<int>::max();
Book::Book()
{
}
void Book::update( Order order ) {
std::cout << order.getSize();
}
I am new to cpp. I seem to be doing the same with the book class as with the order class, where it works fine. This is very confusing. Any pointers?
So, out of curiosity, I created a new projected and added a class TestA and run it, all went fine. Then I created class TestB exactly the same way and it breaks with the same error for TestB, but not TestA
#include <QCoreApplication>
#include "testa.h"
#include "testb.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
TestA A;
TestB B;
return a.exec();
}
testa.h
#ifndef TESTA_H
#define TESTA_H
class TestA
{
public:
TestA();
};
#endif // TESTA_H
testb.h
#ifndef TESTB_H
#define TESTB_H
class TestB
{
public:
TestB();
};
#endif // TESTB_H
throws this
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl TestB::TestB(void)" (??0TestB@@QEAA@XZ) referenced in function main
That is all on qt creator. It just seems very weird behaviour