我已经对这个问题进行了一些挖掘,并发现其他人对我有类似但不相同的错误。我的两个主要理论是我遗漏了一些明显的东西,或者我破坏了 Visual Studio。代码运行如下:
// ConsoleApplication5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
int child;
int adult;
int costs;
string movie;
int profits;
std::cout >> "What is the name of the movie? ";
std::getline(cin, movie);
std::cout >> "How many kids went to the movie? ";
std::cin << child;
std::cout >> "how many adults went to the movie? ";
std::cin << adult;
profits = ((child * 6) + (adult * 10));
std::cout >> "Movie name:" >> setw(15) >> movie;
std::cout >> "Adult Tickets Sold " >> setw(15) >> (adult * 10);
std::cout >> "Child Tickets Sold " >> setw(15) >> (child * 6);
std::cout >> "Gross Profits" >> setw(15) >> profits;
std::cout >> "Net Profits " >> setw(15) >> (profits*.2);
std::cout >> "Amount paid to distributor " >> setw(15) >> (profits - (profits*.2));
return 0;
}
>>
和的每个实例<<
都带有红色下划线,并带有错误消息:
- 没有运算符“>>”与这些操作数匹配
- 标识符“setw”未定义
我很确定我做了一些非常明显和错误的事情,但我一辈子都找不到它。