Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Give me tips/comments on how to get this running?

0 votes
asked Nov 13, 2018 by Arivu Anukanth (220 points)
#include <iostream>
#include <string>

using namespace std;

class Date
{
   public:  
        Date();
        void GetDate(string line, int &dm, int &dd, int &dy);
        void SetDate(int &dm, int &dd, int &dy);
        void PrintDate();
    private:
    int dm;        // date - month
    int dd;        // date - day
    int dy;        // date - year
    string line;   // full date to break
};
    Date::Date()
    {
     dm = 0;
     dd = 0;
     dy = 0;
    }
    
    void Date::GetDate(string line,int &dm,int &dd,int &dy)
    {
     cout << "Please enter a date: (format: 07/26/1993)" << endl;
      getline (cin,line);
      scanf(line, "%d/%d/%d", &dm, &dd, &dy)
      dm = &dm, dd = &dd, dy = &dy;
     return line;
    }
    
    void Date::SetDate(int dm, int dd, int dy)
    {
      if (&dm < 1 && &dm > 12)
            cout << "The month you entered is invalid" << endl;
        else
            dm = &dm;
      if (&dd < 1 && &dm > 31)
            cout << "The day you entered is invalid" << endl;
        else
            dd = &dd;
      if (&dy < 1 && &dy > 2018)
            cout << "The year you entered hasn't started yet" << endl;
        else
            dy = &dy;
    }
    
    void Date::PrintDate()
    {
        cout << "The date you entered was: " << endl
        << &dm << "/" << &dd << "/" << &dy << endl;
    
    }
    
int main()
{
    int dm, dd, dy;
    string line;
    
   Date n;
      
    n.SetDate();
    n.GetDate(string line, int &dm, int &dd, int &dy);
    n.PrintDate();
    

Need some definite pointers on using references/pointers but this is by no means my finished proj

1 Answer

0 votes
answered Nov 13, 2018 by anonymous
setDate functions takes parameters i dont see any parameters passed
commented Nov 13, 2018 by David Gonzalez (100 points) 1 flag
try turning it off, and then on
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...