Daniel Duque

1

votes
1

answer
49

views

How to organize template-functions and functions, in headers and source files

I am learning to use template functions and organize my code in multiple files. I looked at Why can templates only be implemented in the header file? where they point out I should implement my template-functions in the header; I also looked at C++ inline functions: declare as such, define as such, o...
Daniel Duque
1

votes
1

answer
123

views

Aligning Columns in matplotlib.pyplot.figtext

(towns_n and Towns are two arrays each with 50 numbers and names respectively) count = 0 for number,town in zip(towns_n,Towns): textString += (number +'.'+ town).ljust(35) count += 1 if count == 6: count = 0 textString += '\n' plt.figtext(0.13,0.078,textString) My problem is that I want to plot 6...
Daniel Duque
0

votes
0

answer
23

views

Curiously Recurring Template Pattern with static and const private members

I have the following template class: template class virtualCard { private: static int numCards; const int maxCards; public: virtualCard(int); //I want to manage all card construction from here virtual ~virtualCard(); virtual void activate() = 0; }; template int virtualCard::numCards = 0; template v...
Daniel Duque
0

votes
1

answer
38

views

Is it bad class design if a child does not need all protected members of a parent class?

I am learning about classes, abtract classes, and inheritance in C++. I am writting a small personal proyect that plays Cluedo. So far I am thinking about a base class: class player { protected: std::string name,character,position; std::string* hand; public: //things he can do }; And then have a com...
Daniel Duque
0

votes
0

answer
15

views

overload operator+ only for specific case of the class

I have a class matrix where I want to overload the + operator but only if both matrices have the same number of rows and columns. class matrix { private: int rows, columns; double* data; public: //things here: constructor, destructor etc. matrix operator+ (const matrix&) const; }; Then I only want t...
Daniel Duque
-1

votes
0

answer
21

views

std::string out of range eventhough I am not using any index

I get the following error message: string subscript out of range. I believe it has more to do with my templates definition because I am not using any string subscripts anywhere. I have not been able to figure this out, I have tried defining and implementing my templates in various ways but the resul...
Daniel Duque
1

votes
0

answer
14

views

Is a fully specialized template function the same as a regular function?

If I have: template bool name (std::string); template bool name(std::string); What is the difference between the fully specialized function and my other regular functions. For example in the header I would have to have these declarations plus the template definition; nevertheless I can have the sp...
Daniel Duque
0

votes
1

answer
12

views

how to get Mongoose findById response inside a map function of lodash?

I have an array with ids and I need to look for those ids in a collection called Users (collection and model exists) to get information about the user with that id. var emails = _.map(toSendEmails,function(id){ var userEmail = User.findById(id, function(err, user) { return user.email; }); return use...
Daniel Duque