Printing a string with a class in C++? -


#ifndef date_h #define date_h  #include <iostream> #include <iomanip> using namespace std;  class date{ private:     unsigned int day;     unsigned int month;     string monthname;     unsigned int year; public:     date();     void printnumeric() const;     void printalpha() const; }; #endif 

my header file

#include "date.h" #include <string> using namespace std;   date::date(){     month = 1;     monthname = "january";     day = 1;     year = 1970; }  void date::printnumeric() const{     cout << month << "/" << day << "/" << year; }  void date::printalpha() const{     cout << date::monthname << " " << day << ", " << year; } 

and actual code. printnumeric function works fine according testbed printalpha not producing string month name. supposed monthname produce user input month name?

remove date:: , should work


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -