Jest to kawałek przepisany z książki i nie działa. Nie wiecie czemu?
#include <cstdlib>
#include <iostream>
using namespace std;
ostream& operator<<(ostream& os, const Date& d){
char fillc=os.fill("0");
os<<setw(2)<<d.getMonth()<<"-"<<setw(2)<<d.getDay()<<"-"<<setw(4)<<setfill(fillc)<<d.getYear();
return os;
}
int main(int argc, char *argv[])
{
cout<<"asd";
system("PAUSE");
return EXIT_SUCCESS;
}
Wywala mi takie błędy:
13 C:\Users\DELL\Desktop\main.cpp expected ,' or
...' before '&' token
13 C:\Users\DELL\Desktop\main.cpp ISO C++ forbids declaration of Date' with no type C:\Users\DELL\Desktop\main.cpp In function
std::ostream& operator<<(std::ostream&, int)':
15 C:\Users\DELL\Desktop\main.cpp setw' undeclared (first use this function) 15 C:\Users\DELL\Desktop\main.cpp
d' undeclared (first use this function)
18 C:\Users\DELL\Desktop\main.cpp `setfill' undeclared (first use this function)