我目前正在研究字符串,并且正在研究这个简单的示例。我试图在 logSuccess 字符串中传递“生日” 用户输入。做了很多谷歌搜索,但还没有找到解决方案。有提示吗?
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
std::string birthdate;
void printString(const std::string& string)
{
std::cout << string << std::endl;
}
void getBirthdate()
{
std::cout<<"When is your birthday? "<<std::endl;
cin>>birthdate;
}
int main()
{
std::string name = std::string("Dame") + " hello!";
std::string logSuccess = std::string("Thank you! We will send you a postcard on ") + birthdate;
printString(name);
getBirthdate();
printString(logSuccess);
std::cin.get();
}