是下面的代碼安全(它在DEBUG): void takesPointer(const Type* v);//this function does read from v, it doesn't alter v in any way
Type getValue();
...
takesPointer(&getValue());//gives warning while compiling "n
假設我想將一個臨時對象傳遞給一個函數。有沒有辦法做到這一點在1行代碼與2,結構? 隨着一類,我可以這樣做: class_func(TestClass(5, 7));
給出: class TestClass
{
private:
int a;
short b;
public:
TestClass(int a_a, short a_b) : a(a_a), b