samedi 26 mai 2018

Only defined inside a class

#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;
class Meny
{
public:
    void Meny2()
    {
        cout << "Welcome " << Name << LastName;
    }
};

class Kund
{
public:
    string  Name, LastName, personnummer;

    void LoggaIn()
    {
        cout << "Please enter your full name: " << endl;
        cin >> Name >> LastName;
        cout << "Please enter your social security number: " << endl;
        cin >> personnummer;
    }
};

So currently cout << "Welcome " << Name << LastName; wont work because Name and LastName are undefined in the Meny class, is there a way to make them be defined even though they are defined in another class?

Aucun commentaire:

Enregistrer un commentaire