Those CPP details

Source: Internet
Author: User

Implicit conversion of 1.char* type to bool type
void a (bool input)
{
cout<< "I AMD First" <<endl;
cout<<input<<endl;
}
void A (const string &input)
{
cout<< "I amd Second" <<endl;
cout<<input<<endl;
}
int main (int argc,char **argv)
{
A ("str"); is the second a function called?
A (String ("str"));
return 0;
}
The char* type of "Str" is implicitly converted to type bool.

2. Use #pragma pack (1) in pairs:
First to introduce the background, I have a server here, will call a so at runtime, normally everything is normal, but after referring to a third party to the header file, in the call so a function of the core will drop. Baffled, and went to look at the definition of the third-party header file:
#ifndef Header_openapilog_protocol
#define Header_openapilog_protocol
#pragma pack (1)
Some structure definitions
#endif
Only the #pragma pack (1) was called and the #pragma pack () was not called at the end of the file! And my keynote server was recompiled, but so did not recompile, causing its common structure to be a byte-aligned one without doing it.

Those CPP details

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.