Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate UML class diagram from C++

Tags:

c++

uml

I have these 2 structs and 1 class and I want to convert them into UML class:

struct cat
{
std::string name;
int id;
};

struct dog
{
std::string name;
std::string owner;
int age;
};

class Pet
{
std::vector<cat> cats;
std::vector<dog> dogs;
//some methods
};

i made this: class diagram thank you in advance


1 Answers

Some remarks :

  • cat and dog are C++ struct => their members are public, not private
  • you missed to indicate the types of name, id, owner and age
  • you used associations navigable in the two directions, but a cat and a dog do not know the corresponding Pet
  • the association end must be named (cats / dogs), and it is useless to also show them through attributes

So, also adding the modifiers I speak about in the comments of your question :

enter image description here (I use cat/dog rather than Cat/Dog to follow the C++ code, but to use Cat/Dog is better)

like image 56
bruno Avatar answered Dec 21 '25 23:12

bruno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!