I am trying to develop a very basic windows forms application.
I have a class called class1 and another called game. It is my understanding that the autogenerated form1.h is also a class. Maybe this is because i don't understand.
Anyway from game i can declare a pointer of type class1 and access class1's data members, functions etc from a function inside game. I can also declare a pointer of type form1. However when i come to access form1's data members using this pointer it won't let me alter them it just says:
error C2227: left of '->richtextbox1' must point to class/struct/union/generic typ
Here is the code:
//game.h
#pragma once
class class1; //I was told these lines make this class aware of the
class form1; //other class it needs to access.
class game
{
public:
int room;
form1* form1;
class1* class1;
game(void);
public:
int travel(game game);
virtual ~game(void);
};
//game.cpp
#include "StdAfx.h"
#include "game.h"
game::game(void)
{
}
game::~game(void)
{
}
game::travel(game game)
{
class1->datamember =2; //this line works fine
form1->richtextbox1 ="hello world"; //this dies horribly
return 0;
}
I would be extremely grateful to anyone who could help me. Thanks