NAMESPACE ERROR'...不是名称空间名称'

时间:2019-12-30 18:41:39

标签: c++ file c++11 namespaces

我开始学习c ++并进行命名空间练习 我对namspaces有问题

这是三个文件:

dane3.h

using namespace std;
namespace xddd
{
   const int QUARTERS = 4;
   struct Sales
   {
    double sales[QUARTERS];
    double average;
    double Max;
    double Min;
   };

   void setSales(Sales & s, const double ar[], int n);
   void showSales(const Sales & s);
}

dane2.cpp

using namespace std;
#include <iostream>

#include "dane3.h"
namespace xddd
{
    void setSales(Sales & s, const double ar[], int n)
    {
        int point1 = ar[0];
        int point2 = ar[0];
        int point3 = 0;

        for (int i = 1; i < n; i++)
        {
            if (point1 > ar[i])
                point1 = ar[1];
        }

        for (int i = 1; i < n; i++)
        {
            if (point2 < ar[i])
                point2 = ar[1];
        }

        for (int i = 0; i < n; i++)
            point3 += ar[i];

        s.average = point3;
        s.Max = point2;
        s.Min = point1;
    }

    void showSales(const Sales & s)
    {
        cout << s.average << "\n";
        cout << s.Max << "\n";
        cout << s.Min;
    }
}

main.cpp

#include <iostream>
using namespace std;
#include "dane3.h"
using namespace xddd;
int main()
{
    Sales a;
    double table[4] = {10,20,30,40};
    setSales(a,table,QUARTERS);
    showSales(a);
}

我得到了错误:

 'xddd' is not a namespace-name

我认为该错误非常简单,但我不知道如何解决 顺便说一句,如果我犯了一些错误,对我的英语感到抱歉:D

0 个答案:

没有答案