Unable to assign pointers across classes?

Yup, I'm new. Having a problem that is stumping the class atm.

#include <iostream>
#include <string>

using namespace std;

class Node
{
public:
string ID;

Node *nextNode; // Used to create circular link list of "Nodes"

void setLink(Node *nextNode); // Used to set nextNode above
};

class Player
{
public:
string Name;

Player *location; // want to set to the address of a Node defined above
// This will then keep track of where "Player xxx" is
// in the circular link list above.
};

int Main()
{
Node *go, *mdAve; // just setting 2 nodes - Yes this is a Monopoly game - haha
go = new Node("GO"); // assume we have constructors...etc... this all works
mdAve = new Node("Mediteranean Avenue");

go->setLink(mdAve); // Creating a 2 length circ link list. Again, this all works fine
mdAve->setLink(go);

Player *player1; // Create a pointer to a player1 object
player1 = new Player("Name"); // this works - created via constructor

// Here's what we can't figure out how to get this to work:
player1->location = go; // Trying to set the pointer "location" setup in Player class
// to point to go's location.

I've tried every combination of this and the error is this same:

error C2440: '=' : cannot convert from 'Node *' to 'Player *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

So how is it possible to set *location within the Class Player to that of any of the objects created with Node.
I know the easy fix is to track each player by say putting player1, player2, ... player 100 if I wanted in Node and create objects that just utilized that variable as that seems to work as there's none of this "Cross Class" stuff going on.

I'm hoping it's my newbness to C++ that's causing me to miss something.

Thanks!

Peter
Location is a Player*. Therefore, you cannot assign a Node* to it. Make location a Node* instead of a Player*.
I thought I tried that - Apparently not - Works and makes sense - Thanks firedraco!
Topic archived. No new replies allowed.