Small fix of your immediate problem:
Your variable b
is not a pointer and the operator->
b->line.push_back(nc);
will therefore not work. You have to use the operator.
b.line.push_back(nc);
C++
is not C#
(mini code review)
You write that you are coming from C#. There are a lot of stylistic differences between the two languages that you should be aware off. I don't know C#, but here is a 2nd take on your code, taking care of the sorest points (I'm commenting out the header inclusions as it doesn't work on the online compiler I use)
// noble_card.h
#include <string>
class noble_card
{
public: // single section of public stuff (are you sure you don't need private data?)
std::string name; // never do: "using namespace std;" in a header!
int id;
int vp;
noble_card(int _vp);
// compiler-generated default constructor is just fine here
};
// noble_card.cpp
noble_card::noble_card(int _vp): vp(_vp) {} // initialize member in initializer-list
// board.h
// #include "noble_card.h"
#include <deque>
class board
{
public: // single section of public stuff (are you sure you don't need private data?)
std::deque<noble_card> line; // never do: "using namespace std;" in a header!
// compiler generated default constructor and destructor are just fine here
};
// board.cpp (not necessary for your current impl)
// #include "board.h" // takes care of "noble_card.h"
// main.cpp
int main()
{
board b;
for (unsigned i = 0; i < 12; ++i) {
b.line.emplace_back(i); // C++11 allows you to construct-in-place
}
}
You should Google this site to get in-depth explanations of the points that I write in the above code behind the //
comments.