Topic
  • No replies
maurofen
maurofen
2 Posts

Pinned topic Linking an instance of a template class to another object

‏2019-05-22T15:44:45Z |

Hello everybody,

I'm trying to model what i accomplish with the following code:

#include <iostream>

template <typename T>
class A {
public :
    void setItsT(T* pT);

    void go();

protected :
   T* itsT;             //## link itsT_Task
};

template <typename T>
void A<T>::go() {
    itsT->start();
}

template <typename T>
void A<T>::setItsT(T* pT) {
    itsT = pT;
}

struct B
{
    void start() { std::cout << "started!" << std::endl; }
};

int main()
{
    A<B> myA;
    B myB;

    myA.setItsT(&myB);
    myA.go();
}

In Rhapsody (i am on 8.1.5):

1) I created the class template. The itsT relation is modeled using a simple association. Note: in the actual project, this class resides in another package that i imported read-only.

2) I created the class B and its object, myB

3) I created the template instantiantion A<B>, and its object, myA

 

Now i would like to connect myA and myB, in order to accomplish setItsT's effect, but i am not pulling it off.... I tried with an object model diagram, but when i try to link the 2 objects i can't find the itsT relation.

What am i doing wrong?

 

Thanks in advance! :)