Consider following function:

void func(const char & input){
 //do something
}

Apparently it makes sense for the parameter to be constant value not
reference to constant, Now may a compiler optimize that to constant
value so that it'll be the same as following ?

void func(const char input){
 //do something
}

>Now may a compiler optimize that to constant value so that it'll be the same as following?
Yes. Will it? Probably not. The only meaningful optimization here is memory footprint, and then only for the handful of types that are likely to be smaller than a reference. It's not worth the extra complexity of optimizing for such a small gain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.