0

I write the code like this

class A{
// ...
public:
insert(int key, char* contents){ ... }
}

and want to use

A.insert(1, "hellow world");

but does not allow conversion from string literal to char*

how can use like this way?

Danh
  • 5,916
  • 7
  • 30
  • 45

1 Answers1

0

A string literal is a const char*.

class A{
    // ...
    public:
    insert(int key, const char* contents){ ... }
}

// ...
A.insert(1, "hello world");
cdonat
  • 2,748
  • 16
  • 24