본문 바로가기

카테고리 없음

class and public, private

#include "stdafx.h"

#include <iostream>

#include <string>


using namespace std;


class Account {

private:

string id = "myID";

string password = "myPW";

public:

bool QueryLog(const string &id, const string &pw);

};


int main()

{

Account acc;


//acc.id = "FirstID";

//acc.password = "myPW";

if (acc.QueryLog("myID", "myPW"))

{

cout << "로그인에 성공하였습니다. " << endl;

}



    return 0;

}


bool Account::QueryLog(const string &id, const string &pw)

{

return this->id == id && this->password == pw;

}