Sign in to follow this  
BloodLust666

friend class problems

Recommended Posts

I have 2 classes "cApplication" and "cSystem". i want ALL the functions and members available of cSystem publically to cApplication. i tried putting "friend class cSystem" in cApplication, but it keep saying that when i use a function from the cSystem class in a cApplication variable, it says undeclared identifier...

Share this post


Link to post
Share on other sites
Did you include the cSystem header in the cApplication header?


// main.cpp ---------------------------------------
#include "app.h"
#include "system.h"

int main() {
system s;
app a;
a.getsys( s );
}

// system.h ---------------------------------------
#pragma once

class system {
friend class app;
int i;
};

// app.h ------------------------------------------
#pragma once

#include "system.h"

class app {
public:
void getsys( system &s ) {
s.i;
}
};

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this