We have a class like below:
NamesOfData GetNamesOfData()
{
NamesOfData names =
{
"AAA",
"BBB"
};
return names;
}
Now I have a structure that has to have names as mentioned above along with other fields:
struct A
{
std::string name;
...other fields...;
};
I can have the name easily duplicated to create rows of strut values:
struct A Data [] =
{
"AAA",.......;
"BBB", ......;
};
But the issue is that I need to ensure the integrity of names within struct and externally defined - which can be broken any time if the names are modified at any place.
Is there a way design that the issue mentioned above can be overcome or rather having names centrally but easily mapped by both the places?
Aucun commentaire:
Enregistrer un commentaire