-Preview option showed up blank-
I'm new to c++. I learned tutorials from learncpp and was practicing everything I learned from couple chapters. IDE i'm using is VS 2019. This is my first time on any code related forum.
I created a practice program (C++ Practice.cpp) which would have account names and passwords from various websites hard-coded into it. These accounts E.G hotmail() or youtube() are functions.
I created a single class called 'Acc' for every website account. I then created a separate cpp file (Accounts.cpp) and header (Accounts.h) for the accounts class.
***
Problem is that the account functions are now being ignored when called from the C++ "Practice.cpp" and I don't understand why. The program runs without errors and warnings. But when being called from the selectMenu() function with switch it doesn't perform any account function calls.
***
For example if I was to enter 4 it would work fine by printing the list back, but doing 1,2,3 would give nothing back.
I'm sure to make mistakes relating to bad practice, but please do point it out.
(C++ Practice.cpp)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <iostream>
#include <string>
#include "Accounts.h"
//Global variables
std::string quit = { "" }; //Unused for now
//Accounts access key called acs
Acc acs;
void selectMenu() {
std::string prtmenu{ "0: All\n1: Hotmail\n2: Youtube\n3: GOG\n4: Menu\n" };
std::cout << prtmenu;
while (quit != "Q") { //Q is unused. Change select to char later whenever ¯\_(ツ)_/¯
std::string prtChoice{ "Your choice is currently " };
unsigned short select{};
std::cin >> select;
switch (select)
{
case 0:
std::cout << prtChoice << "All\n";
acs.hotmail(); std::cout << "\n";
acs.youtube(); std::cout << "\n";
acs.gog();
break;
case 1:
std::cout << prtChoice;
acs.hotmail();
break;
case 2:
std::cout << prtChoice;
acs.youtube();
break;
case 3:
std::cout << prtChoice;
acs.gog();
break;
case 4:
std::cout << prtmenu;
break;
};
};
};
void logon() {
std::string passWord{ "Pass" };
std::string ipassWord{ "" };
std::cout << "Enter Password: ";
std::cin >> ipassWord;
if (ipassWord == passWord) {
selectMenu();
}
else {
logon();
}
};
int main()
{
logon();
selectMenu();
return 0;
};
|
(Accounts.cpp)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <string>
#include "Accounts.h"
std::string prtUsername{ "Username: " };
std::string prtPassword{ "Password: " };
std::string prtSecurity{ "Security: " };
void hotmail() {
std::string hm_UserName{ "LegitUser" };
std::string hm_passWord{ "LegitPass" };
std::string hm_security{ "Themepark, Blackjack, ..." };
std::cout << "Hotmail\n";
std::cout << prtUsername + hm_UserName + "\n";
std::cout << prtPassword + hm_passWord + "\n";
std::cout << prtSecurity + hm_security + "\n";
};
void youtube() {
std::string yt_UserName{ "Susan Wojcicki" };
std::string yt_passWord{ "BestCEO_XD" };
std::string yt_security{ "Family Friendly, Demonitised ..." };
std::cout << "youtube\n";
std::cout << prtUsername + yt_UserName + "\n";
std::cout << prtPassword + yt_passWord + "\n";
std::cout << prtSecurity + yt_security + "\n";
};
void gog() {
std::string gog_UserName{ "Marcin Iwinski" };
std::string gog_passWord{ "ItsCrunchTimebooiis!" };
std::string gog_security{ "Management, Overtime ..." };
std::cout << "GOG\n";
std::cout << prtUsername + gog_UserName + "\n";
std::cout << prtPassword + gog_passWord + "\n";
std::cout << prtSecurity + gog_security + "\n";
};
|
(Accounts.h)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#pragma once
#ifndef ACCOUNTS_H
#define ACCOUNTS_H
class Acc {
public:
void hotmail() {
};
void youtube() {
};
void gog() {
};
};
#endif
|