tags:

views:

61

answers:

1

hey there I stuck at defining a static pointer inside one of my class which is pointing to another class here is the schema of what I've done :

#busineslogic.h
class BussinesLogic {

private :
static Samenamespace::otherclass_DataLogic::clsDL *DL;
 };

#busineslogic.cpp
 samenamespace {
 businessnamespace{
 clsBL{

   Samenamespace::businessnamespace::clsBL *Samenamespace::businessnamespace::clsBL::DL;
  }
 }
}

so with above definition I'll get error every time I compile the code , I've tried several other ways to overcome this problem but the face of the errors gonna change not the whole problem.

I want to know how can I access to another class from my class in such a static way I mean something like above example , how should I change my code ? or should add something extra?

+3  A: 
// header:
#include <other/b.hpp>

namespace example {
struct A {
  static other::B* name;
};
}


// implementation: (.cpp)
namespace example {
other::B* A::name;
}

Edit: With the cleanup of the question, it looks like B and A are in the same namespace, which would simplify the example:

// header:
#include <example/b.hpp>

namespace example {
struct A {
  static B* name;
};
}


// implementation: (.cpp)
namespace example {
B* A::name;
}
Roger Pate
thanks for the answer , thats the exact point which I've been stucking on for two hours . I have another question I've came from C# and c++ isn't my main programming language but I know the basic aspect of c++ could you please tell me if I want to learn c++ in a way to not cope with above problem which book or source is suitable for me?shall I start from scratch? or is there any shortcut available?regards.
austin powers
I'm not sure what you're asking there. There are several good C++ books, such as Accelerated C++ (http://www.acceleratedcpp.com/).
Roger Pate