go
3587 / 1367 / 130
Регистрация: 16.04.2009
Сообщений: 4,527
|
30.01.2012, 20:21
|
|
Например так
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| #include <iostream>
class obj
{
private:
std::string s;
public:
obj(const std::string _s = ""): s(_s) {};
obj(const char s_[]): s (s_) {};
std::string show() { return s; };
};
int main()
{
obj a1, a2("abc"), a3 = "Hello world";
std::cout << a1.show() << std::endl << a2.show() << std::endl << a3.show() << std::endl;
} |
|
http://liveworkspace.org/code/03decdbf978fdf2fee346dfcfbecb4a6
0
|