It’s my first time asking for help here. When I try to compile the code I get the following errors. I’m using VS Code and sometimes, after a write more code, i get these errors. I have attached some screenshots with the two errors. I’m using C/C++: g++.exe when building my file.
//main.cpp
#include <iostream>
#include "Client.h"
using namespace std;
int main()
{
Client client("user123", "password", "John", "Doe", "123-456-7890", "123 Main St");
client.getClient();
client.CreateAccount();
client.Login();
return 0;
}
//User.h
#ifndef USER_H
#define USER_H
#include <string>
class User {
public:
User();
User(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, const std::string&);
void Login();
void CreateAccount();
private:
std::string username;
std::string password;
std::string Name;
std::string LastName;
std::string PhoneNumber;
std::string Address;
};
#endif
//User.cpp
#include "User.h"
#include <string>
#include <iostream>
User::User(const std::string &username ,const std::string &password,const std::string &Name, const std::string &LastName, const std::string &PhoneNumber, const std::string &Adress )
:username(username),password(password), Name(Name), LastName(LastName), PhoneNumber(PhoneNumber), Address(Adress) {}
void User::CreateAccount()
{
std::cout<<"Create your account: n";
std::cout<<"Enter your username: n"; std::cin>>username;
std::cout<<"Enter your password: n"; std::cin>>password;
std::cout<<"Enter your name: n";
std::cin>>Name;
std::cout<<"Enter your last name: n"; std::cin>>LastName;
std::cout<<"Enter your phone number: n"; std::cin>>PhoneNumber;
std::cout<<"Enter your adress: n";
std::cin>>Address;
}
void User::Login()
{
while(true)
{
std::cout<<"Enter your username: "; std::cin>>username;
std::cout<<"Enter your password: "; std::cin>>password;
if(this->username == username && this->password == password)
{
std::cout<<"Login succesful!";
// AppSystem();
break;
}
else std::cout<<"Invalid email or password n";
}
}
//Client.cpp
#include "Client.h"
#include <string>
#include <iostream>
Client::Client(const std::string &username ,const std::string &password, const std::string &Name, const std::string &LastName, const std::string &PhoneNumber, const std::string &Address )
: User(username, password, Name, LastName, PhoneNumber, Address) {}
void Client::getClient() const
{
std::cout << "Client Information:n";
std::cout << "Username: " << username << "n";
std::cout << "Name: " << Name << "n";
std::cout << "Last Name: " << LastName << "n";
std::cout << "Phone Number: " << PhoneNumber << "n";
std::cout << "Address: " << Address << "n";
}
//Client.h
#ifndef CLIENT_H
#define CLIENT_H
#include <string>
#include "User.h"
class Client : public User
{
public:
Client(const std::string& ,const std::string&, const std::string&, const std::string&, const std::string&, const std::string&):username(username),password(password), Name(Name), LastName(LastName), PhoneNumber(PhoneNumber), Address(Address) {}
void getClient() const;
private:
std::string username;
std::string password;
std::string Name;
std::string LastName;
std::string PhoneNumber;
std::string Address;
};
#endif
//tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\msys64\ucrt64\bin\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
//settings.json
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
{
//launch.json
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/GLM21/Desktop/Mailfood - proiect",
"program": "c:/Users/GLM21/Desktop/Mailfood - proiect/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
//c_cpp_properties.json
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
enter image description here
enter image description here
New contributor
Luca Gavra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.