I started learning c++ and have namespace exercise I have some problem with namspaces
These are three files:
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);
}
I get the error:
'xddd' is not a namespace-name
I think that error is very simple, but i dont know how to figure it BTW sorry for my english if I made some mistakes :D
Aucun commentaire:
Enregistrer un commentaire