小编Tat*_*ili的帖子

如果字符串向量包含char'p',如何检查c ++

1)假设我有一个v巫师向量(向导有一个名字,姓氏,字符串向量,其中包括他/她参加的主题以及他/她所属的房子)

2)我有一个空向量cpy,我想在其中复制那些参加主题的向导,其中带有字母“ p”。

就我而言,我只想复制劳拉,因为她参加运动,这是唯一包含“ p”的主题。

//wizard.cpp
Wizard::Wizard(string name, string lastname, Vector<string> subjects, Haus haus) :
  name{name}, lastname{lastname}, subjects{subjects}, haus{haus}
{
  if (name.empty() || lastname.empty() ){
    throw runtime_error("name or lastname wrong");
  }
}

string Wizard::get_name() const {
  return name;
}

string Wizard::get_lastname() const {
  return lastname;
}

Vector<string> Wizard::get_subjects() const {
  return subjects;
}

Haus Wizard::get_haus() const {
  return haus;
}

Vector<Wizard> v;
Wizard harry("Harry", "Potter", {"magic", "music"}, Haus::Gryffindor);
Wizard ron("Ron", "Weasley", {"magic", "dancing"}, Haus::Gryffindor);
Wizard hermione("Hermione", …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm iterator copy c++-standard-library

1
推荐指数
2
解决办法
136
查看次数

标签 统计

algorithm ×1

c++ ×1

c++-standard-library ×1

copy ×1

iterator ×1