#pragma once #include <iostream> #include <cstring> using namespace std; class Menu { private: string title; public: Menu( void ); Menu( const Menu &unMenu ); ~Menu( void ); void setTitle ( string title ); string getTitle() const; };
Menu.cpp
#include "Menu.h" Menu::Menu(void) { this->title = "Hello"; } Menu::Menu(const Menu &unMenu) { this->title = unMenu.title; } Menu::~Menu(void) { } /////////////////////////////////////////////////// void Menu::setTitle( string title ) { this->title = title; } string Menu::getTitle() const { return ( this->title ); }
main.cpp
#include "Menu.h" #include <iostream> #include <cstring> using namespace std; int main () { Menu m; m.setTitle( "Spider Man 3" ); cout << m.getTitle(); system("PAUSE"); return 0; }
I'm getting a problem when i put
cout << m.getTitle();