Answer the question
In order to leave comments, you need to log in
Should I create a separate class?
whether it is necessary to create separate classes for each of the tasks "create object triangles", "create object mesh", "create object texture", if each of these classes contains only 2-3 functions - one "create", the second (third) is internal , auxiliary? or is it better to create three global functions "create object mesh", "create object triangles", "create object texture" ? each of the functions would have 2-3 parameters.
Answer the question
In order to leave comments, you need to log in
It's easier to work with finite objects.
We come up with a logical structure that will contain the data. At the same time, the structure should be such that it is convenient to use it several times.
Example:
1) There are orders in the system, we create the Order class
2) There are services, we create the Service class
3) There are basic services - services that describe the main meaning, for example - Macaroni and cheese, this is a basic service, each Service class has a pointer either to number of the corresponding base service (class BaseService)
Order stores numbers or a pointer to the services included in the order, that is, instances of the Service class.
Service stores a number or pointer to the BaseService that describes the meaning of this instance of the Service class,
In general, in a simple sense, classes are wrapped in a structure that is often repeated. At the same time, each class can describe the methods necessary to work with this structure. For example - serialize or deserialize.
Create a factory with a static method.
class factory {
public:
static void* create(enum obj_type) {
switch(obj_type) {
case e_rect : return create_rect();
...}
private:
static void* create_rect(){}
...
};
class rect{
public:
static rect* create( );
private:
rect();
...
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question