Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Strings & Classes (http://www.go4expert.com/forums/strings-classes-t7628/)

Max_Payne_007 29Nov2007 23:56

Strings & Classes
 
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();

shabbir 30Nov2007 09:03

Re: Strings & Classes
 
What is the problem you are getting?


All times are GMT +5.5. The time now is 10:01.