我正在尝试创建一个使用智能指针创建帐户对象的小程序,但是我的代码似乎有错误。我的代码有什么问题?
#include <iostream>
#include <memory>
class Account {
public:
std::string name;
int balance;
Account(std::string s) : name{s} {}
void deposit(int m) {balance=+m;}
void withdraw(int m) {balance=+m;}
};
int main()
{
std::unique_ptr <Account> p1 {new Account {"Larry"}};
std::cout << *p1 << std::endl;
p1->deposit(1000);
p1->withdraw(500);
return 0;
}