Hi guys
where is the problem with that simple class program:

#include<iostream>
#include<conio.h>
using namespace std;
class DayOfYear
{
      public:
             DayOfYear(int month,int day);
             void output();
             void input();
      private:
              int month_year;
              int day_year;
};
DayOfYear::DayOfYear(int month,int day)
{
    month_year=month;
    day_year=day;
}
void DayOfYear::output()
{
     cout<<month_year<<"/"<<day_year;
}
void DayOfYear::input()
{
     cout<<"What's your month of birthday : ";
     cin>>month_year;
     cout<<"What's your day of birthday : ";
     cin>>day_year;
}


int main()
{
    cout<<"The program will use class and a regular function and represent some kind of connection between them"<<endl;
    DayOfYear bach_birthday(3,21),my_birthday;
    cout<<"The birth of Bach is : ";
    bach_birthday.output();
    cout<<"\nNow I will ask you about your birthday"<<endl;
    cout<<"What is your month and day of birthday : ";
    my_birthday.input();
    my_birthday.output();     

    getch();
    return 0;
}

You tell us..? we're not mind readers.

What problem are you having? does it compile? if not, what error message(s) do you get?

Can't you copy it and try to compile yourself. wouldn't be much easier and simpler and more readable. Anyway ,this program doesn't compile. There is an error message:
41 no matching function for call to `DayOfYear::DayOfYear()'
Do you know what is it mean
Thanks

I could - but there's no guarantee that what happens when I try compiling & running it, is going to be the same as what happens when you try compiling & running it (Especially not when you've missed out CODE tags, and your code has got forum icons in it... )

The error you're getting is because the compiler can't find a default constructor in the DayOfYear class.

When you write your own constructor, the default constructor is no longer available automatically, so you either have to make one, or change your code in main, so that its using the constructor you've already written..

DayOfYear bach_birthday(3,21),my_birthday;

Hej
And one more question. I understand what you are saying, but I don't know how to aplay it. How may I create new default constructor and where can I place it, that everything will work in that particular program.
Thanks a lot

Just create a constructor in your DayOfYear class, which takes no parameters... just like you've done here

#include<iostream>
#include<conio.h>
using namespace std;
class DayOfYear
{
public:
[B]    DayOfYear(int month,int day);[/B]
    void output();
    void input();
private:
    int month_year;
    int day_year;
};
[B]DayOfYear::DayOfYear(int month,int day)
{
    month_year=month;
    day_year=day;
}[/B]
void DayOfYear::output()
{
    cout<<month_year<<"/"<<day_year;
}
void DayOfYear::input()
{
    cout<<"What's your month of birthday : ";
    cin>>month_year;
    cout<<"What's your day of birthday : ";
    cin>>day_year;
}

Great,it works. Thanks a lot

Mauro, more than 30 posts and you still don't use code tags?

commented: Some people just never get it... +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.