Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualblackfe2010

Posted 01 November 2012 - 08:37 AM

Hi,

I'm a beginner about boost.
And i try to write some code like:

#include "stdafx.h"
#include <boost/shared_ptr.hpp>
class A;
class B;
class A
{
public:
A() {};
boost::shared_ptr<B> a;
boost::shared_ptr<B> b;
};
class B
{
public:
B(){};
boost::shared_ptr<A> a;
boost::shared_ptr<A> b;
};
int _tmain(int argc, _TCHAR* argv[])
{
A a;
B b;
a.a=boost::shared_ptr<B>(&b);
a.b=boost::shared_ptr<B>(&b);
b.a=boost::shared_ptr<A>(&a);
b.b=boost::shared_ptr<A>(&a);
return 0;
}

This program is crash.
Who can tell me what's happend?

#1blackfe2010

Posted 01 November 2012 - 08:36 AM

Hi,

I'm a beginner about boost.
And i try to write some code like:

#include "stdafx.h"
#include <boost/shared_ptr.hpp>
class A;
class B;
class A
{
public:
A() {};
boost::shared_ptr<B> a;
boost::shared_ptr<B> b;
};
class B
{
public:
B(){};
boost::shared_ptr<A> a;
boost::shared_ptr<A> b;
};
int _tmain(int argc, _TCHAR* argv[])
{
A a;
B b;
a.a=boost::shared_ptr<B>(&b);
a.b=boost::shared_ptr<B>(&b);
b.a=boost::shared_ptr<A>(&a);
b.b=boost::shared_ptr<A>(&a);
return 0;
}


Who can tell me what's happend?

PARTNERS