hello!
i have a problem with my code,it keeps crashes at the following point:

[B]a.h[/B]
class Value{
   .....
   public:
     Value(char* b);
}

class A{
	private:
        .......
	 Value* value; 
       ........  
      public:
          A(char* tok);
}

a.cpp

A::A(char* tok){
.......
  *value = Value(tok)
......}

i can tell i do something wrong with the pointer but i cant find it..

So value is a pointer, that is supposed to point to an object of type Value (awful choice of name for your pointer, by the way; really, really awful - if you can't think of a better name, at least call it something that makes it clear it's not Value - pToObjectOfTypeValue would be clumsy but so much better, for example). Where did you make that Value object that it will point to? Where did you make the pointer actually point at it?

Looks to me like you never did; just making a pointer doesn't magically create something for it to point to. That's up to you. So when you do this:

*value

you're trying to get to an object that was never created. The pointer will be pointing to some random place in memory, and then when you try to write over that random place like this:

*value = Value(tok)

you're trying to access memory that doesn't belong to you, so you get an access violation error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.