Click here to Skip to main content
15,945,112 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get System Current language Pin
Perspx7-Aug-08 10:11
Perspx7-Aug-08 10:11 
JokeRe: Get System Current language Pin
David Crow8-Aug-08 4:00
David Crow8-Aug-08 4:00 
QuestionDirectX lib file question Pin
followait7-Aug-08 6:30
followait7-Aug-08 6:30 
AnswerRe: DirectX lib file question Pin
Mark Salsbery7-Aug-08 6:42
Mark Salsbery7-Aug-08 6:42 
GeneralRe: DirectX lib file question Pin
followait7-Aug-08 19:53
followait7-Aug-08 19:53 
GeneralRe: DirectX lib file question Pin
Mark Salsbery8-Aug-08 3:50
Mark Salsbery8-Aug-08 3:50 
GeneralRe: DirectX lib file question Pin
followait8-Aug-08 20:54
followait8-Aug-08 20:54 
QuestionClass definition issue Pin
Patrick G7-Aug-08 4:57
Patrick G7-Aug-08 4:57 
Hello,

I'm trying to recreate a problem that I'm having in another project and have created a small overly simple project to experiment with. That being said, I'm being blocked by what seems like a really silly problem.

So, I have two classes: ClassA and ClassB. ClassB's constructor takes a pointer to ClassA as a parameter for later use. The compiler seems not to mind that, however it does not like when I try to use the pointer that is passed. Here's some code:

//ClassA.h
#pragma once;

#include <iostream>
using namespace std;

#include "ClassB.h"
class ClassB;

class ClassA {
public:
	ClassA () {
		this->b = new ClassB(this);
	}

	void printer() {
		cout << "Hello world from A!\n";
	}

private:
	ClassB* b;

};


And a little more:

//ClassB.h
#pragma once;

#include <iostream>
using namespace std;

#include "ClassA.h"
class ClassA;

class ClassB {
public:
	ClassB(ClassA *a) {
		this->ca = a;
		cout << "Constructor B \n\n";
		ca->printer();
	}

private:
	ClassA *ca;
};


and finally a main to polish it off:

#include <windows.h>

#include <iostream>
using namespace std;

#include "ClassA.h"
#include "ClassB.h"

void main() {
	ClassA a;
	Sleep(10000);
}


I get two errors with this setup. They both point to ca->printer(); in the ClassB.h file. They are Error 1 error C2027: use of undefined type 'ClassA' classb.h 14 and Error 2 error C2227: left of '->printer' must point to class/struct/union/generic type classb.h 14 .

Oddly enough, this isn't even the problem I'm trying to recreate from my larger project (I don't have this problem there). I'm actually trying to recreate an access violation on the call to the constructor of the class that ClassB represents (then the program continues, but it never executes the constructor).

Anyway, I'll settle for figuring out what the silly mistake I'm making is that's blocking the compiler from finishing the job.

Thanks for your help!
AnswerRe: Class definition issue Pin
Cedric Moonen7-Aug-08 5:04
Cedric Moonen7-Aug-08 5:04 
GeneralRe: Class definition issue Pin
Patrick G7-Aug-08 5:33
Patrick G7-Aug-08 5:33 
QuestionCalling exported functions from a static DLL Pin
Yashusid7-Aug-08 4:01
Yashusid7-Aug-08 4:01 
AnswerRe: Calling exported functions from a static DLL Pin
Matthew Faithfull7-Aug-08 4:18
Matthew Faithfull7-Aug-08 4:18 
GeneralRe: Calling exported functions from a static DLL Pin
Yashusid7-Aug-08 4:40
Yashusid7-Aug-08 4:40 
GeneralRe: Calling exported functions from a static DLL Pin
led mike7-Aug-08 4:44
led mike7-Aug-08 4:44 
GeneralRe: Calling exported functions from a static DLL Pin
Matthew Faithfull7-Aug-08 4:53
Matthew Faithfull7-Aug-08 4:53 
GeneralRe: Calling exported functions from a static DLL Pin
Yashusid7-Aug-08 5:15
Yashusid7-Aug-08 5:15 
GeneralRe: Calling exported functions from a static DLL Pin
Matthew Faithfull7-Aug-08 5:29
Matthew Faithfull7-Aug-08 5:29 
GeneralRe: Calling exported functions from a static DLL Pin
Yashusid8-Aug-08 0:59
Yashusid8-Aug-08 0:59 
AnswerRe: Calling exported functions from a static DLL Pin
Cedric Moonen7-Aug-08 4:23
Cedric Moonen7-Aug-08 4:23 
AnswerRe: Calling exported functions from a static DLL Pin
toxcct7-Aug-08 4:25
toxcct7-Aug-08 4:25 
QuestionAre THE MFC FTP classes limited to 32bit file sizes? Pin
Paul Deckers7-Aug-08 3:48
Paul Deckers7-Aug-08 3:48 
AnswerRe: Are THE MFC FTP classes limited to 32bit file sizes? Pin
led mike7-Aug-08 4:41
led mike7-Aug-08 4:41 
QuestionPassing string array as pointer Pin
__DanC__7-Aug-08 3:47
__DanC__7-Aug-08 3:47 
AnswerRe: Passing string array as pointer Pin
David Crow7-Aug-08 4:01
David Crow7-Aug-08 4:01 
GeneralRe: Passing string array as pointer Pin
__DanC__7-Aug-08 4:11
__DanC__7-Aug-08 4:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.