K
kk_oop
Hi. I want class B to have a member of class A. Class A's constructor
takes an int parameter. Here are the classes:
Here's A.h*****************
#ifndef A_H_
#define A_H_
class A
{
public:
A(int theX);
virtual ~A();
private:
int x;
};
#endif /*A_H_*/
Here's B.h********************
#include "A.h"
class B
{
public:
B();
virtual ~B();
A a(10); //this causes an error
};
#endif /*B_H_*/
*********************
The declaration of A gives me an error. What is the correct way to do
this?
Thanks!
Ken
takes an int parameter. Here are the classes:
Here's A.h*****************
#ifndef A_H_
#define A_H_
class A
{
public:
A(int theX);
virtual ~A();
private:
int x;
};
#endif /*A_H_*/
Here's B.h********************
#include "A.h"
class B
{
public:
B();
virtual ~B();
A a(10); //this causes an error
};
#endif /*B_H_*/
*********************
The declaration of A gives me an error. What is the correct way to do
this?
Thanks!
Ken