编译器中发生内部错误。
f:\vs2013documents\visual c++2013入门经典\visual c++2013入门经典\person.h(35): fatal error C1001: 编译器中发生内部错误。
1> (编译器文件“msc1.cpp”,第 1325 行)
1> 要解决此问题,请尝试简化或更改上面所列位置附近的程序。
1> 请选择 Visual C++
1> “帮助”菜单上的“技术支持”命令,或打开技术支持帮助文件来获得详细信息。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
头文件:
// Person.h
// A class defining a person
#pragma once
#include <iostream>
#include <string>
class Person
{
public:
Person(const std::string first, const std::string second) :
firstname{ std::move(first) }, secondname{ std::move(second) } {}
Person() = default;
// Less-than operator
bool operator<(const Person& p)const
{
return (secondname < p.secondname ||
((secondname == p.secondname) && (firstname < p.firstname)));
}
// Greater-than operator
bool operator>(const Person& p)const
{
return p < *this;
}
// Output a person
void showPerson() const
{
std::cout << firstname << " " << secondname << std::endl;
}
private:
std::string firstname{};
std::string secondname{};
};
源文件:
// Ex10_09.cpp
// Exercising a priority queue container
#include <vector>
#include <queue>
#include <functional>
#include "Person.h"
int main()
{
std::priority_queue<Person, std::vector<Person>, std::greater<> > people;
std::string first, second;
while (true)
{
std::cout << "Enter a first name or press Enter to end: ";
std::getline(std::cin, first);
if (first.empty())
break;
std::cout << "Enter a second name: ";
std::getline(std::cin, second);
people.push(Person{ first, second });
}
std::cout << "\nThere are " << people.size() << " people in the queue." << std::endl;
std::cout << "\nThe names that you entered are:" << std::endl;
while (!people.empty())
{
people.top().showPerson();
people.pop();
}
}
各位高手怎么解决?