C++ C++;所有声明都需要类型说明符&;预期的非限定id(需要调试帮助)
编辑* 我对代码做了一些修改,并解决了主要问题。有几行仍然有这些错误,所以我认为,关于通常是什么修复了这些类型的错误以及它们的实际含义,应该只剩下一些。谢谢你们C++ C++;所有声明都需要类型说明符&;预期的非限定id(需要调试帮助),c++,debugging,types,specifier,C++,Debugging,Types,Specifier,编辑* 我对代码做了一些修改,并解决了主要问题。有几行仍然有这些错误,所以我认为,关于通常是什么修复了这些类型的错误以及它们的实际含义,应该只剩下一些。谢谢你们 #include <iostream> #include "RetailItem.h" using namespace std; int main() { RetailItem *item1 = nullptr; RetailItem * item2 = nullptr;
#include <iostream>
#include "RetailItem.h"
using namespace std;
int main()
{
RetailItem *item1 = nullptr;
RetailItem * item2 = nullptr;
RetailItem * item3 = nullptr;
//objects
item1 = new RetailItem; // c++ requires a type specifier for all declarations
item2 = new RetailItem; // c++ requires a type specifier for all declarations
item3 = new RetailItem; // c++ requires a type specifier for all declarations
//first item
std::cout << "Please enter the price for the first item." << endl; //expected unqualified-id
std::cout << "Price must be greater than 0: " << endl; //expected unqualified-id
cin >> retailPrice; //expected unqualified-id
while (retailPrice < 0) //loop //expected unqualified-id
{
cout << "Price must be greater than 0." << endl;
cout << "Please try again: " << endl;
cin >> retailPrice;
}
item1 = setPrice(retailPrice); // c++ requires a type specifier for all declarations
cout << "Please enter number of items in inventory for item 1: " //expected unqualified-id
cin >> retailUnitsOnHand;
while(retailUnitsOnHand < 0) //expected unqualified-id
{
cout << "Inventory must be greater than 0." << endl;
cout << "Please enter number of items in inventory for item 1: "
cin >> retailUnitsOnHand;
}
item1 = setUnitsOnHand; // c++ requires a type specifier for all declarations
}
#包括
#包括“RetailItem.h”
使用名称空间std;
int main()
{
RetailItem*item1=nullptr;
RetailItem*item2=nullptr;
RetailItem*item3=nullptr;
//物体
ItEM1=新零售;//C++需要所有声明的类型说明符
ItEM2=新零售;//C++需要所有声明的类型说明符
ItEM3=新零售;//C++需要所有声明的类型说明符
//第一项
std::cout您的代码需要在函数中
i、 e
intmain();
-->intmain(){
这是一次编写过多代码的明显例子。你犯的错误意味着即使是一行代码也无法编译。在没有编译和测试的情况下,不要编写超过几行的代码。只有当你感到满意时,你才应该编写接下来的几行代码。不要让编程变得更加困难天哪,我甚至没有意识到我在int main()之后放了;我很抱歉。我还有其他问题,但这对他们帮助很大。谢谢大家!我想我只是需要另一双眼睛。
int main() {