小编kun*_*nir的帖子

Const和非const引用绑定

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’.

对不起,我的英语不好.

c++ compiler-errors

5
推荐指数
1
解决办法
1473
查看次数

g_key_file_get_string()如何工作?

我无法理解这个函数如何返回字符串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)

抱歉英语不好.

c memory-leaks glib

1
推荐指数
1
解决办法
1435
查看次数

标签 统计

c ×1

c++ ×1

compiler-errors ×1

glib ×1

memory-leaks ×1