Hello, I am currently working with data structures in C ++ with xcode 8.3.3, my problem is as follows:
1.- Using templates, the derived class does not recognize the variables of the base class despite having been declared as protected.
2.- It asks me to initialize all my variables, even though they are initialized in the constructor.
3.- If the recommendations of the xcode are made (initialize variables and add the variables of the base class in the derived class) it allows me to execute the program without presenting errors or precautions but when running the program it stops in a line of the program and presents The following message (Thread 1: EXC_BAD_ACCESS (code = 1, address = 0x01).
It is worth mentioning that the program does not have syntax error, since this same program (with templates) I have run in visual studio and it works perfectly, in Xcode I have executed it without the templates works perfectly, but when adding the templates it stops working.
Is there a rule to work with templates in xcode?
Thanks for helping.
regards.
How to use templates in c ++?
Hello Albert2018,
Templates in C++ are an advanced topic. You would have to post the source for anyone to be able to make any recommendations. When using templates, C++ can get very strange. What you describe could very well be correct interpretation of your code. Perhaps Visual Studio is using an older C++ standard by default. There is no way to tell without said code. If it is crashing, then there is likely a bug somewhere.