Sam Creamer
Sam Creamer

Reputation: 5361

C++ Error LNK2001, cannot find error

I am learning C++ right now and I've been stuck on this for 30 minutes. Here is my code:

#include <iostream>
using namespace std;

class Card
{
public:
 Card();
private:
 int rank;
 int suit;
};

int main()
{
 Card card1;
 return 0;
}

I'm still new to c++ but I can't see why this is not working, I am getting error LNK2001 and other topics of the same nature haven't helped (because I'm a noob).

If someone could help me I'd appreciate it a lot, thanks

Upvotes: 1

Views: 68

Answers (1)

Floris Velleman
Floris Velleman

Reputation: 4888

Your constructor for the class Card is not specified. Try using:

Card() {
}

Or (outside the class):

Card::Card() {
}

Live demo

Upvotes: 4

Related Questions