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

c# - OpenXML hanging while writing elements -

php - regexp cyrillic filename not matches -

sql - Select Query has unexpected multiple records (MS Access) -