0
class A{
// ...
public:
insert(int key, char* contents){ ... }
}
的代碼,並希望使用
A.insert(1, "hellow world");
,但不允許從字符串文字轉換爲char *
如何可以使用這樣的方式?
class A{
// ...
public:
insert(int key, char* contents){ ... }
}
的代碼,並希望使用
A.insert(1, "hellow world");
,但不允許從字符串文字轉換爲char *
如何可以使用這樣的方式?
文字串是一個const char*
。
class A{
// ...
public:
insert(int key, const char* contents){ ... }
}
// ...
A.insert(1, "hello world");
的可能的複製[這是在C和C++字符串文字的類型?](http://stackoverflow.com/questions/2245664/what-is-the-type-of-string-literals-在-C-和-C) – Danh
僅使用C++字符串文字 – jjj111144444