+ 2

Can anyone explain me the token pasting operator in preprocessor..?

11th Jun 2017, 4:49 AM
Prahar pandya
Prahar pandya - avatar
7 Réponses
+ 5
The ##x preprocessor operator is used to glue things together in the preprocessor code. It is a concatenation operator which can join two literals, tokens, anything into a single one.. Eg #define cat(x,y) cout<<x##y; main() { cat("a","b"); //ab cat(2,3); //23 cat('a',2); //a2 } You may also enter types here, but they may not work in this one... But they may work in cases where you wish to create the variables at runtime or overload them for all types... Eg - https://code.sololearn.com/cT79Zt0zSHSo/?ref=app This uses ##x to get a data type and create a structure for that datatype, thus, allowing the user to use the same structure for more than one data type... Read more here: https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html
11th Jun 2017, 5:32 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
yep
11th Jun 2017, 5:06 AM
Prahar pandya
Prahar pandya - avatar
+ 3
Okk..Thank you @kinshuk 😊👍
11th Jun 2017, 5:37 AM
Prahar pandya
Prahar pandya - avatar
+ 2
You mean ##x?
11th Jun 2017, 5:06 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
@Prahar pandya Welcome...
11th Jun 2017, 6:59 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar