Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i am trying to code a program to sort and list some data. I use a vector with my class so every entry got its own object. But i realized i may want to add more tags/categorys to every entry and to store this new data i need a new variables or new functions in my class. How can i add something like variables and Getter + Setter to my class without having to know which new categorys i am going to add?

What I have tried:

I tried to do something with the constructor but i think thats not right. I used an array instead of vector.
Posted
Updated 11-Sep-16 22:26pm
Comments
Philippe Mori 10-Sep-16 18:15pm    
Where is your code? Also show us what you would like to do.

1 solution

I think you should do some design wor with UML to clarify what you want to code. Here is a tutorial. An easy solution is also to draw it at paper - best with a pencil.

Dont knowing the type of the variables is bad style.

You can do such stuff by adding a dictionary which has a key (your var) and a value (the value).

A common design pattern is interface. You define some compatible functions but not the class.

An advice from a seasoned developer: if you dont know WHAT to implement your work is for the trashcan. ;-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900