私は、次のC++クラスがあります:あなたが見ることができるようにC++のnoob - クラススコープ
class Eamorr {
public:
redispp::Connection conn;
Eamorr(string& home, string& uuid)
{
//redispp::Connection conn("127.0.0.1", "6379", "password", false); //this works, but is out of scope in put()...
conn=new redispp::Connection("127.0.0.1", "6379", "password", false); //this doesn't work ;(
}
put(){
conn.set("hello", "world");
}
...
}
を、私はconn
はput()
方法でコンストラクタと利用可能に初期化することにしたいです。
どうすればいいですか?事前に
多くのおかげで、
これは機能します!どうもありがとうございます! – Eamorr