简体   繁体   中英

how to generate UML class diagram from C++

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:类图 thank you in advance

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:

在此处输入图像描述 (I use cat/dog rather than Cat/Dog to follow the C++ code, but to use Cat/Dog is better)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM