I am just starting out with RTI Connext using Modern C++. I'm trying to make a class that has a DomainParticipant and some other stuff and am getting errors.
In Foo.h:
#include "dds/domain/DomainParticipant.hpp"
class Foo {
public:
Foo(int32_t domain);
private:
dds::domain::DomainParticipant part;
And in Foo.cpp:
#include "Foo.h" Foo::Foo(int32_t domain) { }
When I try to compile it (and remember there's literally nothing going on) I get an error at the constructor:
error C2248: 'dds::domain::TDomainParticipant<rti::domain::DomainParticipantImpl>::TDomainParticipant': cannot access private member declared in class 'dds::domain::TDomainParticipant<rti::domain::DomainParticipantImpl>' C:\Program Files\rti_connext_dds-6.0.1\include\ndds\hpp\dds/domain/TDomainParticipant.hpp(127): note: see declaration of 'dds::domain::TDomainParticipant<rti::domain::DomainParticipantImpl>::TDomainParticipant' C:\Program Files\rti_connext_dds-6.0.1\include\ndds\hpp\dds/domain/detail/domainfwd.hpp(36): note: see declaration of 'dds::domain::TDomainParticipant<rti::domain::DomainParticipantImpl>'
Any idea what might be going on?
A DomainParticipant and the Entity-derived objects need to be explicitly initialized; they don't provide a default constructor.
You can do this:
Or:
For more information, make sure to read the API basic conventions:
https://community.rti.com/static/documentation/connext-dds/6.0.1/doc/api/connext_dds/api_cpp2/group__DDSCpp2Conventions.html
That's exactly what I needed, thanks! Your first example fixed the problem I posted about, and the second fixed a different problem I was having where I wanted to initialize something outside of the constructor.