A forward problem case 1 works case 2 not

I dont understand nothing

I have

ClassA.h
1
2
3
4
5
   class B;
   class A {
   public:
   private:
   }

ClassA.cpp
1
2
3
4
5
  #include "classb.h"
  ClassA::function(){
   Classb *clasb;
   clasb->function();
  }

It works .

But this one not :
ClassA.h
1
2
3
4
5
6
   class B;
   class A {
   public:
   Classb *clasb; // I want to use in several places ...
   private:
   }

ClassA.cpp
1
2
3
4
  #include "classb.h"
  ClassA::function(){
  clasb->function();
  }


At the second case, I have :
Invalid use in static ClassA::clasb static member.

Is that than I cannot create public or private objetcs using forward?
Thanks

Last edited on
Even your explanation is not good enough to answer your question, from my guess I think you are trying to use non-static class member in static function. That compiler won't allow you to do like this. Because static members are independent of class objects, means those are common to all objects of that class. But, non-static is dependent of class objects. Trying to Access non-static member from static function is like breaking integrity of the class objects. So, please try to understand what you are trying or post questions clearly to get answered.
Topic archived. No new replies allowed.