1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Strings & Classes

Discussion in 'C++' started by Max_Payne_007, Nov 29, 2007.

  1. Max_Payne_007

    Max_Payne_007 New Member

    Menu.h

    Code:
    
    #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

    Code:
    #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

    Code:
    
    #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();
     
  2. shabbir

    shabbir Administrator Staff Member

    What is the problem you are getting?
     

Share This Page