【问题标题】:symbol(s) not found for architecture x86_64 error on mac osxmac osx 上未找到架构 x86_64 错误的符号
【发布时间】:2016-09-12 03:54:43
【问题描述】:

我目前正在学习 C++ 课程。我在 MAC OSX 上使用 Eclipse Luna。我不确定这个错误信息。Snap of Error Message 什么可能导致编译错误?

代码只是为果汁机设计一个支付系统。

谢谢。

#include <iostream>
#include <string>
using namespace std;

void disProduct (string);

int main ()
{
int choice;
string orange, apple, mango, strawberryBanana;

cout << "1 for orange juice \n"
     << "2 for apple juice \n"
     << "3 for mango juice \n"
     << "4 for strawberry-banana juice \n"
     << "9 to exit \n";

cin >> choice;

switch(choice)
{
    case 1:disProduct(orange);
            break;
    case 2:disProduct(apple);
            break;
    case 3:disProduct(mango);
            break;
    case 4:disProduct(strawberryBanana);
            break;
}

return 0;
}

void dispProduct (string name)
{
int vend;
cout << "please enter 50 cents";
cin >> vend;

while (vend > 0)
{
    if(vend < 50)
        {
        cout << "Please enter the remaining amount of " << 50-   vend;
        }

    if (vend >= 50)
        {
        cout << "please take your "<< name <<"juice and change
    << in the     amount of " << vend - 50;
        }
}

}

【问题讨论】:

  • switch-case 语句中应该有一个default 选项。
  • 好奇,choice的数据类型是什么?
  • int 类型。感谢您的默认评论。我已经解决了。但问题仍然存在。
  • 你不应该#include &lt;string&gt; 吗?你有没有比这个没有提供任何信息的可怕日食日志更好的控制台?
  • 谢谢琼。我已经包含了字符串库。这是 Luna 给我的唯一信息。

标签: c++ macos eclipse-luna


【解决方案1】:

声明的函数原型为void disProduct (string);,但实际定义为void dispProduct (string name),两者名称不同。

并且还要添加string 标头。

【讨论】:

    猜你喜欢
    • 2014-09-01
    • 2018-08-20
    • 2015-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多