void swap(int& a, int& b) {}
void copy(int& a, const int& b) {}
int main() {
int a=1;
unsigned b=2;
swap(a, b);
copy(a, b);
}
Run Code Online (Sandbox Code Playgroud)
C++语言,g ++编译器.
请告诉我为什么copy -function调用中没有编译错误,但是在swap -function触发器中invalid initialization of reference of type ‘int&’ from expression of type ‘unsigned int’.
对不起,我的英语不好.
我无法理解这个函数如何返回字符串gchar*.
它是否为字符串存储动态分配内存?那么,在这种情况下,内存泄漏可能吗?
typedef char gchar;
gchar *g_key_file_get_string(GKeyFile *key_file,
const gchar *group_name,
const gchar *key,GError **error)
Run Code Online (Sandbox Code Playgroud)
抱歉英语不好.