Post: [C++] Is This a good Place to learn C++?
02-06-2011, 04:56 PM #1
Girby2K11
☮ ☯ ☢ ✔ ➝
(adsbygoogle = window.adsbygoogle || []).push({}); over the last month i have been reading this website and book.
the website is called You must login or register to view this content.

and i am reading this book called c++ for dummies by Stephan R. Davies

i am at the start of the book and website but i was wondering is it a good place to understand all the coding of c++ and be able to write full gui's?
02-10-2011, 06:25 PM #11
Superman.
Is it a bird? ... Is it a plane?
yes, that site is one of the best places to learn
02-10-2011, 07:52 PM #12
anddrew
League Champion
a very good place Happy
    
if(confused user == "noob" && confused user == "stupid post"){
other users thread DoFlame();
}


liking me code?
02-10-2011, 09:02 PM #13
Originally posted by anddrew View Post
a very good place Happy
    
if(confused user == "noob" && confused user == "stupid post"){
other users thread DoFlame();
}


liking me code?


That would not work in C++.
02-10-2011, 09:22 PM #14
anddrew
League Champion
Originally posted by TheUberFail View Post
That would not work in C++.


It would in mw2's version of c++ Winky Winky

it was meant as a joke.
02-10-2011, 10:17 PM #15
Girby2K11
☮ ☯ ☢ ✔ ➝
Originally posted by TheUberFail View Post
I can help you understand pointers, they are a very easy to understand once you have been taught properly what they really are.

Ok, so you probably understand the concept of memory addresses and the fact they store data, but sometimes when explaining pointers, some tutorial kind of forget to highlight the key features of a pointer that make it difficult to understand.

To start, when declaring a pointer,

int myNumber;
int *intPointer;

bool myBool;
bool *boolPointer

Now, the pointer here is not a integer value, or a boolean value, they are actually a data type of pointer it self, all int *pointer means is, here, i have a pointer data type called intPointer, and when you point, you are pointing at a data type of a integer. now wait a second, what does, pointing at a data type of int really mean?

When pointing at a int, you are telling the computer, to look at memory location #, but remember, and integer is 4 bytes big, so it will have to look at the next 4 memory locations to get the data required to make up an integer, the same for a boolean pointer, it will only look at one byte (boolean size).

How to use pointers.

Try to think of a pointer as a location data type, it can only store a location.

    
int myNumber = 50;
int *myPointer;

myPointer = &myNumber;
//& sign translates to, "Memory address of: "

*myPointer = 100;
//* Translates to, "Value of address: "

if(myNumber==100)
//This statement now is true



wow i never knew it was that easy to understand.

---------- Post added at 05:17 PM ---------- Previous post was at 05:15 PM ----------

Originally posted by anddrew View Post
a very good place Happy
    
if(confused user == "noob" && confused user == "stupid post"){
other users thread DoFlame();
}


liking me code?


i see what your trying t do, you have mixed up data types and function like 'other people on NGU Flame' and as UberFail said that wont work.
02-10-2011, 10:25 PM #16
Originally posted by Girby2K11 View Post
wow i never knew it was that easy to understand.

---------- Post added at 05:17 PM ---------- Previous post was at 05:15 PM ----------



i see what your trying t do, you have mixed up data types and function like 'other people on NGU Flame' and as UberFail said that wont work.


Only way this word work is by using a type def template for confused, and in Mw2, the only reason this works in Mw2 is because Active vision have used class based multiprocessing.
02-10-2011, 10:57 PM #17
anddrew
League Champion
Originally posted by TheUberFail View Post
Only way this word work is by using a type def template for confused, and in Mw2, the only reason this works in Mw2 is because Active vision have used class based multiprocessing.


Originally posted by Girby2K11 View Post

i see what your trying t do, you have mixed up data types and function like 'other people on NGU Flame' and as UberFail said that wont work.



Ok I am the confused user :S

I'll just leave the C++ area Happy
02-10-2011, 11:29 PM #18
Originally posted by anddrew View Post
Ok I am the confused user :S

I'll just leave the C++ area Happy


    

#include <iostream>
#include <string>
#include <map>
#include <fstream>
#include "drawMenu.h"
#include "stringEncryption.h"

class CLogin
{
public:
short index;
map <short,string> username;
map <string,string> password;
string logInStatus;
void addUser();
void delUser(short id);
void display(short id);
void displayAll();
void changeUser(short id);
void logOut();
void handel(short id,bool& quit);
void saveFile();
void loadFile();
void eraseAll();
}storage;
void CLogin::addUser()
{
string tempUser,tempPass;
bool doContinue=0;

for(;Winky Winky
{
system("CLS");
cout<<"\n\tEnter a username: ";
getline(cin,tempUser);

if(tempUser=="")
{
system("CLS");
cout<<"\n\tNo username entered!";
Sleep(2000);
continue;
}

doContinue=0;

for(int i=index;i>0;i--)
if(username[i]==tempUser)
{
system("CLS");
cout<<"\n\tUser already exists!";
Sleep(2000);
doContinue=1;
}
if(doContinue)
continue;

for(;Winky Winky
{
system("CLS");
cout<<"\n\tEnter a password: ";
getline(cin,tempPass);

if(tempPass=="")
{
system("CLS");
cout<<"\n\tNo password entered!";
Sleep(2000);
continue;
}

break;
}
break;
}
index++;
username[index] = tempUser;
password[tempUser] = tempPass;
}
void CLogin::delUser(short id)
{
if(username[id]==logInStatus)
logInStatus = "Not Logged In";
for(int i=id;i<=index;i++)
{
username[i]=username[i+1];
password[username[i]]=password[username[i+1]];

password.erase (username[i+1]);
username.erase (i+1);
}
index--;
}
void CLogin::display(short id)
{
system("CLS");
cout<<"\n\tAccount id: "<<id;;
cout<<"\n\tAccount name: "<<username[id];
cout<<"\n\tAccount pass: "<<password[username[id]];
cout<<"\n\n\t";
system("PAUSE");
}
void CLogin::handel(short id,bool& quit)
{
if(id>index)
{
quit = 1;
return;
}

string message="Edit user: ";
message+=username[id];
bool boolReturn = 0;

for(;Winky Winky
{
system("CLS");
cout<<endl;

switch(drawMenu(message,"Display details|Delete|Return",1))
{
case 1: display(id); break;
case 2: delUser(id); boolReturn=1; break;
//case 3: changeUser(id); break;
case 3: boolReturn=1; break;
}
if(boolReturn)
return;
}
}
void CLogin::displayAll()
{
string users;
bool secondLayerQuit = 0;

for(;Winky Winky
{
system("CLS");
users = "";
if(index>0)
{
users+=username[1];
for(int i=2;i<index;i++)
{
users+="|";
users+=username[i];
}
if(index>=2)
{
users+="|";
users+=username[index];
}
users+="|";
users+="Return";
}
else
{
cout<<"\n\tNo users in the database!";
cout<<"\n\t";
system("PAUSE");
return;
}
cout<<endl;
handel(drawMenu("Users in the database",users,1),secondLayerQuit);
if(secondLayerQuit)
return;
}
}
void CLogin::changeUser(short id){
logInStatus=username[id];}
void CLogin::logOut(){
logInStatus="Not logged in";}

void CLogin::saveFile()
{
system("CLS");
string temp;

ofstream filestream;
filestream.open ("encryptedData.dat");

if(filestream)
{
for(int i=1;i<=index;i++)
{
temp = username[i];
enString(temp);
filestream << temp << endl;

temp = password[username[i]];
enString(temp);
filestream << temp << endl;
}
cout<<"\n\tFile saved!";
cout<<"\n\t";
system("PAUSE");
}
else
{
cout<<"\n\tError! Can not write to file!";
cout<<"\n\t";
system("PAUSE");
}
filestream.close();
}

void CLogin::loadFile()
{
string tempString;
cout<<endl;
bool alternate = true;

ifstream filestream ("encryptedData.dat");
if (filestream.is_open())
{
switch(drawMenu("Do you want to overwrite the current database with the savefile?","Yes|No",1))
{
case 1: system("CLS");break;
case 2: system("CLS");return;
}
eraseAll();
while ( filestream.good() )
{
if(alternate)
{
index++;
getline (filestream,tempString);
deString(tempString);
username[index]=tempString;
alternate = false;
continue;
}
else
{
getline(filestream,tempString);
deString(tempString);
password[username[index]]=tempString;
alternate = true;
continue;
}
}
//delUser(1);
cout<<"\n\tFile loaded!";
cout<<"\n\t";
system("PAUSE");
filestream.close();
}
else
{
cout<<"\n\tError! Unable to open file!";
cout<<"\n\t";
system("PAUSE");
}
}

void CLogin::eraseAll()
{
while(index>0)
{
password.erase (username[index]);
username.erase (index);
index--;
}
}

void checkAccess()
{
ifstream filestream ("cache.dat");
if (filestream.is_open())
{
bool alternate = true;
string lockUser,lockPass;
string attemptUser,attemptPass;
while ( filestream.good() )
{
if(alternate)
{
getline (filestream,lockUser);
deString(lockUser);
alternate = false;
continue;
}
else
{
getline(filestream,lockPass);
deString(lockPass);
alternate = true;
continue;
}
}

for(;Winky Winky
{
system("CLS");
cout<<"\n\tThis application requires you to log in!"<<endl;
cout<<"\n\tEnter username: ";
getline(cin,attemptUser);
cout<<"\tEnter password: ";
getline(cin,attemptPass);

if(attemptUser == lockUser && attemptPass == lockPass)
break;
system("CLS");
cout<<"\n\tWrong login!";
cout<<"\n\t";
system("PAUSE");
}
}
else
{
filestream.close();

string setUser,setPass;

ofstream filestream;
filestream.open ("cache.dat");

if(filestream)
{
for(;Winky Winky
{
cout<<"\n\tEnter a username to stop people accessing this application: ";
getline(cin,setUser);
if(setUser!="")
break;
system("CLS");
}
for(;Winky Winky
{
cout<<"\tEnter a password: ";
getline(cin,setPass);
if(setUser!="")
break;
system("CLS");
}
enString(setUser);
enString(setPass);

filestream << setUser << endl;
filestream << setPass<< endl;
filestream.close();
}

else
{
cout<<"\n\tError! Unable to store cache, Exiting program!";
cout<<"\n\t";
system("PAUSE");
}
}
}

int main()
{
checkAccess();
system("CLS");
storage.logInStatus = "Not logged in";
string message;
for(;Winky Winky
{
system("CLS");
message = "";
//message+="Log in system made by TheUberFail, Log in status: ";
//message+=storage.logInStatus;
message+="Password saver by TheUberFail ::Now with encryption!";
cout<<"\n";
switch(drawMenu( message,
"Display Users|Create user|Save|Load|Exit",
1)
)
{
case 1: storage.displayAll(); break;
case 2: storage.addUser(); break;
//case 3: storage.logOut(); break;
case 3: storage.saveFile(); break;
case 4: storage.loadFile(); break;
case 5: return 0;
}
}
}


:/
02-11-2011, 11:15 PM #19
Ritztro
I am a Game Developer
Originally posted by TheUberFail View Post
You are on the right track, you can create simple GUIs with SFML, this means its still Win32 based, to create true window forms with GUIs your self needs a great great deal of C++ skill. once you get there, you are a true programmer.


You dont need to use sfml but you probably want to since there is a Linux and Mac version. Which means you can easily port. But You can just use qt which is cross platform for gui's and Visual C++ Express for gui's on windows.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo