失踪 ”;” 在标识符“名称”之前,即使它在那里

埃里克·奎瓦斯(Eric Cuevas)

这是我的代码:

 #ifndef PROBLEM3_H
 #define PROBLEM3_H

 #include <string>

 struct stackItem {
     // arbritary name do define item
     string name;
 };

 class Hw3Stack {
     public:
         // Default constuctor that prompts the user for the stack
         // capacity, initalizes the stack with the capacity, and the sets
         // the size of zero.
         Hw3Stack();

         // Copy constructor that takes a current stack and copies the
         // current size, capacity, and stackItems into the current object.
         Hw3Stack(Hw3Stack& stack);

         // Destructor that deletes the stack
         ~Hw3Stack();

         // Returns true if there are no items in stack, false otherwise.
         bool isEmpty();

         // Returns the current size of Hw3Stack
         int getSize();

         // Returns the current capacity of the stack.
         int getCapacity();

         // Adds the stackItem to the stack. If the stack is equal to
         // the capacity after insertion, copy all of the current 
         // stackItems into a new array with double the current capacity
         // and set the current stack array to the new array.
         void push(stackItem item);

         // Removes the top stackItem. Returns true if sucessful. Returns 
         // false otherwise (i.e. if the stack is empty).
         bool pop();

         // Returns a reference to the top stackItem, but does not remove
         // the top stackItem. If empty, you may return nullptr.
         stackItem* top();

         // Prints the stack contents’ names from top to bottom.
         void printStack();

     private:
         int capacity; // capacity of the stack
         int size; // current size of the stack
         stackItem* stack; // pointer to the array stack
 };

 int problem3();

 #endif PROBLEM3_H

我收到以下错误:

错误C2146:语法错误:缺少';' 在标识符“名称”之前

错误C4430:缺少类型说明符-假定为int。注意:C ++不支持default-int

我不知道这里出了什么问题,因为我以为自己写的代码正确。Visual Studio在编译前没有告诉我有任何错误,因此将不胜感激。

萨胡

您需要使用:

std::string name;

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

丢失的 ”;” 在标识符“名称”之前,即使它在那里

来自分类Dev

Aapt失踪,但在那里

来自分类Dev

失踪 ”;” 之前“命名空间”和“;” 之前“用”

来自分类Dev

失踪儿童

来自分类Dev

结合失踪

来自分类Dev

失踪儿童

来自分类Dev

月食在月食失踪的树

来自分类Dev

失踪 ; 声明前?

来自分类Dev

查尔斯·代理和失踪

来自分类Dev

听失踪的翻译事件

来自分类Dev

Haskell进口失踪H

来自分类Dev

蓝鸟归还承诺失踪警告

来自分类Dev

TSC之后静态成员失踪

来自分类Dev

TSC之后静态成员失踪

来自分类Dev

删除与父母失踪的孩子记录

来自分类Dev

为什么libnettle 2.7.1的.configure找不到-lgmp,即使它在那里?

来自分类Dev

猫鼬 findOne 不提供文档,即使它在那里

来自分类Dev

失踪的Javadoc JDK的iFrame视图11+

来自分类Dev

Java的String类的replaceAll方法失踪

来自分类Dev

迁移到androidX失踪Android Studio中

来自分类Dev

SequenceInformation检索错误 - 列从结果集失踪

来自分类Dev

想念一个失踪的人呢?

来自分类Dev

失踪 ”!” EnableDelayedExpansion时的字符串

来自分类Dev

下一个身份失踪

来自分类Dev

Devise无法检测到:omniauthable,但是它在那里

来自分类Dev

缺少所需的请求正文,但它在那里

来自分类Dev

img不可见..但是它在那里

来自分类Dev

“类”不包含“方法”的定义,但它在那里

来自分类Dev

即使在两周后仍无法在Google Play商店中找到应用,但是它在那里