これが「あなたの好みは何ですか」という質問の 1 つとして解釈される可能性があることは理解していますが、次の方法のいずれかを選択する理由を知りたいです。
次のような超複雑なクラスがあるとします。
class CDoSomthing {
public:
CDoSomthing::CDoSomthing(char *sUserName, char *sPassword)
{
//Do somthing...
}
CDoSomthing::~CDoSomthing()
{
//Do somthing...
}
};
グローバル関数内でローカル インスタンスを宣言するにはどうすればよいですか?
int main(void)
{
CDoSomthing *pDoSomthing = new CDoSomthing("UserName", "Password");
//Do somthing...
delete pDoSomthing;
}
- また -
int main(void)
{
CDoSomthing DoSomthing("UserName", "Password");
//Do somthing...
return 0;
}